예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the LineStatus EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLineStatus(LineStatus lineStatus)
 {
     base.AddObject("LineStatus", lineStatus);
 }
예제 #2
0
        public bool UpdateLineStatusWithTime(string client, string line, bool on, string strEventTime)
        {
            try
            {
                if (string.IsNullOrEmpty(strEventTime))
                    return false;

                DateTime eventTime;

                if (!DateTime.TryParse(strEventTime, out eventTime))
                    return false;

                using (DB db = new DB())
                {
                    LineStatus lineStat = (from o in db.LineStatus
                                           where o.Client == client
                                           && o.Line == line
                                           select o).FirstOrDefault();

                    bool result = false;

                    if (lineStat != null)
                    {
                        if (on != lineStat.Status || lineStat.Status == true)//Only log False once, but constantly update time for True
                        {
                            lineStat.Status = on;
                            lineStat.EventTime = eventTime;

                            result = db.SaveChanges() > 0;
                        }
                    }
                    else
                    {
                        lineStat = new LineStatus();
                        lineStat.Client = client;
                        lineStat.Line = line;
                        lineStat.Status = on;
                        lineStat.ShiftStart = "06:00:00";
                        lineStat.Timezone = "Eastern Standard Time";
                        lineStat.EventTime = eventTime;

                        db.AddToLineStatus(lineStat);

                        result = db.SaveChanges() > 0;
                    }

                    if (result == true)
                    {
                        DBHelper.UpdateAscommPing(client, DateTime.Now, line, true);
                    }

                    return result;
                }
            }
            catch (Exception ex)
            {
                String fileName = this.Server.MapPath("~/App_Data/log.txt");
                File.AppendAllText(fileName, ex.ToString());
                throw ex;
            }
        }
예제 #3
0
 /// <summary>
 /// Create a new LineStatus object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="timezone">Initial value of the Timezone property.</param>
 public static LineStatus CreateLineStatus(global::System.Int32 id, global::System.String timezone)
 {
     LineStatus lineStatus = new LineStatus();
     lineStatus.ID = id;
     lineStatus.Timezone = timezone;
     return lineStatus;
 }