示例#1
0
        public BatteryItem GetBatteryItem(string itemID)
        {
            //Get a new or existing battery item
            BatteryItem item = null;

            try {
                if (itemID.Length == 0)
                {
                    item = new BatteryItem();
                }
                else
                {
                    BatteryItems items = GetBatteryItems();
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (items[i].ItemID == itemID)
                        {
                            item = items[i]; break;
                        }
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery item.", ex))); }
            return(item);
        }
示例#2
0
        public BatteryItems GetUnassignedBatteryItems(long terminalID)
        {
            //Get unassigned batteries for the specified terminal
            BatteryItems items = null;

            try {
                items = new BatteryItems();
                DataSet ds = fillDataset(USP_BATTERY_UNASSIGNED, TBL_BATTERY_UNASSIGNED, new object[] {});
                if (ds != null)
                {
                    ItemDS itemDS = new ItemDS();
                    itemDS.Merge(ds);
                    for (int i = 0; i < itemDS.BatteryItemTable.Rows.Count; i++)
                    {
                        BatteryItem item = new BatteryItem(itemDS.BatteryItemTable[i]);
                        if (item.TerminalID == terminalID)
                        {
                            items.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading unassigned battery items.", ex))); }
            return(items);
        }
示例#3
0
        public BatteryItems GetBatteryItems()
        {
            //Update collection of battery items
            BatteryItems items = null;

            try {
                items = new BatteryItems();;
                DataSet ds = fillDataset(USP_BATTERY_VIEW, TBL_BATTERY_VIEW, new object[] {});
                if (ds != null)
                {
                    ItemDS itemDS = new ItemDS();
                    itemDS.Merge(ds);
                    for (int i = 0; i < itemDS.BatteryItemTable.Rows.Count; i++)
                    {
                        BatteryItem item = new BatteryItem(itemDS.BatteryItemTable[i]);
                        item.DriverName  = itemDS.BatteryItemTable[i].IsLastNameNull() ? "" : itemDS.BatteryItemTable[i].LastName.Trim();
                        item.DriverName += !itemDS.BatteryItemTable[i].IsLastNameNull() && !itemDS.BatteryItemTable[i].IsFirstNameNull() ? ", " : "";
                        item.DriverName += itemDS.BatteryItemTable[i].IsFirstNameNull() ? "" : itemDS.BatteryItemTable[i].FirstName.Trim();
                        items.Add(item);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery items.", ex))); }
            return(items);
        }
示例#4
0
        public static void ExportBatteryItem(BatteryItem item)
        {
            //Export this object to a text file
            const string TOKEN = ",";

            System.IO.StreamWriter writer = null;
            try {
                writer = System.IO.File.AppendText("c:\\batterys.txt");
                string sEntry = item.TerminalID + TOKEN +
                                item.Terminal.Trim() + TOKEN +
                                item.ItemID + TOKEN +
                                item.TypeID + TOKEN +
                                item.InServiceDate.ToShortDateString() + TOKEN +
                                item.Comments + TOKEN +
                                item.IsActive + TOKEN +
                                item.LastUpdated + TOKEN +
                                item.UserID + TOKEN +
                                item.RowVersion;
                writer.WriteLine(sEntry);
                writer.Flush();
            }
            catch (Exception) { }
            finally { if (writer != null)
                      {
                          writer.Close();
                      }
            }
        }
示例#5
0
 //Interface
 public dlgBatteryItem(BatteryItem item)
 {
     //Constructor
     try {
         InitializeComponent();
         this.mItem = item;
         this.Text  = (this.mItem.ItemID.Length > 0) ? this.mItem.Terminal.Trim() + " Battery (" + this.mItem.ItemID + ")" : this.mItem.Terminal.Trim() + " Battery (New)";
     }
     catch (Exception ex) { throw new ApplicationException("Failed to create new Battery Item dialog", ex); }
 }
示例#6
0
        public bool EndBatteryItemChargeCycle(BatteryItem item)
        {
            //End the charging cycle for this battery item
            bool result = false;

            try {
                result = executeNonQuery(USP_BATTERY_ENDCHARGE, new object[] { item.ItemID, item.LastUpdated, item.UserID, item.RowVersion });
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while ending battery item charge cycle.", ex))); }
            return(result);
        }
示例#7
0
        public static bool EndBatteryItemChargeCycle(BatteryItem item)
        {
            bool ret = false;

            try {
                _Client = new MobileDevicesServiceClient();
                ret     = _Client.EndBatteryItemChargeCycle(item);
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("EndChargeCycle() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("EndChargeCycle() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("EndChargeCycle() communication error.", ce); }
            return(ret);
        }
示例#8
0
        public static BatteryItem GetBatteryItem(string itemID)
        {
            BatteryItem item = null;

            try {
                _Client = new MobileDevicesServiceClient();
                item    = _Client.GetBatteryItem(itemID);
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("GetBatteryItem() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetBatteryItem() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetBatteryItem() communication error.", ce); }
            return(item);
        }
示例#9
0
        public bool SaveBatteryItem(BatteryItem item)
        {
            //Persist this object
            bool result = false;

            try {
                if (item.ItemID.Length == 0)
                {
                    item.ItemID = (string)executeNonQueryWithReturn(USP_BATTERY_CREATE,
                                                                    new object[] { item.ItemID,
                                                                                   item.TypeID,
                                                                                   item.TerminalID,
                                                                                   item.IsActive,
                                                                                   item.Comments,
                                                                                   item.LastUpdated,
                                                                                   item.UserID,
                                                                                   item.RowVersion,
                                                                                   item.MinHoursToCharge,
                                                                                   null, null });
                    result = true;
                }
                else
                {
                    result = executeNonQuery(USP_BATTERY_UPDATE,
                                             new object[] { item.ItemID,
                                                            item.TerminalID,
                                                            item.IsActive,
                                                            item.Comments,
                                                            item.LastUpdated,
                                                            item.UserID,
                                                            item.RowVersion,
                                                            item.MinHoursToCharge });
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while saving battery item.", ex))); }
            return(result);
        }