Esempio n. 1
0
        public async Task <bool> CreateCommunicationInfo(CommunicationInfo communicationInfo)
        {
            try
            {
                if (communicationInfo.CommunicationTypeId > 0)
                {
                    var commType = await dataContext.CommunicationType.FirstOrDefaultAsync(c => c.Id == communicationInfo.CommunicationTypeId);

                    if (commType == null)
                    {
                        throw new Exception("Invalid Communication Type Id");
                    }
                }

                if (communicationInfo.AccountId != null && communicationInfo.AccountId > 0)
                {
                    var account = await dataContext.Account.FirstOrDefaultAsync(a => a.AccountId == communicationInfo.AccountId);

                    if (account == null)
                    {
                        throw new Exception("Invalid Account Id");
                    }
                }

                if (communicationInfo.ContactId != null && communicationInfo.ContactId > 0)
                {
                    var contact = await dataContext.Contact.FirstOrDefaultAsync(c => c.ContactId == communicationInfo.ContactId);

                    if (contact == null)
                    {
                        throw new Exception("Invalid Contact Id");
                    }
                }

                if (communicationInfo.LeadId != null && communicationInfo.LeadId > 0)
                {
                    var lead = await dataContext.Lead.FirstOrDefaultAsync(l => l.Id == communicationInfo.LeadId);

                    if (lead == null)
                    {
                        throw new Exception("Invalid Lead Id");
                    }
                }

                await dataContext.CommunicationInfo.AddAsync(communicationInfo);

                var result = await dataContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public async Task <bool> EditCommunicationInfo(int id, CommunicationInfo communicationInfo)
        {
            try
            {
                var commInfoToEdit = await dataContext.CommunicationInfo.AsNoTracking().FirstOrDefaultAsync(c => c.Id == id);

                if (commInfoToEdit != null)
                {
                    communicationInfo.Id = id;
                    dataContext.CommunicationInfo.Update(communicationInfo);
                    var result = await dataContext.SaveChangesAsync();

                    if (result > 0)
                    {
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
 public ECUFile(string filePath)
 {
     this.FilePath      = filePath;
     VersionInfo        = new VersionInfo();
     CommunicationInfo  = new CommunicationInfo();
     IdentificationInfo = new IdentificationInfo();
     Measurements       = new Measurements();
 }
        private bool ReadLine(string line)
        {
            if (line != null)
            {
                if (this.DataRead != null)
                {
                    this.DataRead(line);
                }

                if (string.IsNullOrEmpty(logConfigFile))
                {
                    logConfigFile = line;
                }
                else if (string.IsNullOrEmpty(ecuCharacteristicsFile))
                {
                    ecuCharacteristicsFile = line;
                }
                else if (string.IsNullOrEmpty(ecuDef))
                {
                    ecuDef = line;
                }
                else if (CommunicationInfo == null && line == "[Communication]")
                {
                    //[Communication]
                    CommunicationInfo = new CommunicationInfo();
                }
                else if (CommunicationInfo != null && !CommunicationInfo.Complete)
                {
                    CommunicationInfo.ReadLine(line);
                }
                else if (IdentificationInfo == null && line == "[Identification]")
                {
                    //[Identification]
                    IdentificationInfo = new IdentificationInfo();
                }
                else if (IdentificationInfo != null && !IdentificationInfo.Complete)
                {
                    IdentificationInfo.ReadLine(line);
                }
                else if (Variables == null && line == "Logged variables are:")
                {
                    //logged variables are:
                    Variables = new SessionVariables();
                }
                else if (Variables != null && !Variables.Complete)
                {
                    Variables.ReadLine(line);
                }
                else if (line.StartsWith("-> Start logging"))
                {
                    SamplesPerSecond = short.Parse(line.Substring(line.IndexOf(",") + 2,
                                                                  line.IndexOf("samples/second") - line.IndexOf(",") - 3));
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        public CommunicationInfo Resolve(ExistAttribute attribute, MethodInfo methodInfo)
        {
            var att      = (ExistResource)attribute;
            var commInfo = new CommunicationInfo {
                Method = att.Method, UriTemplate = m_existResourceManager.GetResourceUriTemplate(att.Type)
            };

            return(commInfo);
        }
Esempio n. 6
0
        /// <summary>
        /// create a service server.
        /// </summary>
        public ServiceServer(IImageController controller, ILoggingService logService)
        {
            //get connection information
            CommunicationInfo com = new CommunicationInfo();

            this.logging = logService;
            this.port    = com.port;
            this.IP      = com.IPNumber;
            clients      = new List <TcpClient>();
            this.handler = new ClientHandler(clients, controller, logService);
        }
Esempio n. 7
0
        internal void InitializeSession(IdentificationInfo identificationInfo, CommunicationInfo communicationInfo, SessionVariables variables)
        {
            bool idinfostarted    = false,
                 commInfoStarted  = false,
                 variablesStarted = false;

            using (StreamReader sr = new StreamReader(logFilePath, Encoding.UTF7))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    if (!identificationInfo.Complete)
                    {
                        if (!idinfostarted)
                        {
                            idinfostarted = line.StartsWith("ECU identified with following data:");
                        }
                        else
                        {
                            identificationInfo.ReadLine(line, true);
                        }
                    }
                    else if (!communicationInfo.Complete)
                    {
                        if (!commInfoStarted)
                        {
                            commInfoStarted = line == "";
                        }
                        else
                        {
                            communicationInfo.ReadLine(line, true);
                        }
                    }
                    else if (!variables.Complete)
                    {
                        if (!variablesStarted)
                        {
                            variablesStarted = line == "";
                        }
                        else
                        {
                            variables.ReadLine(line, true);
                        }

                        if (variables.Complete)
                        {
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public IHttpActionResult SaveCommunications(CommunicationInfo model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Ok());
                }
                if (model.CommunicationID > 0)
                {
                    var existcommunication = _db.CommunicationInfos.FirstOrDefault(x => x.CommunicationID == model.CommunicationID);
                    existcommunication.BuyerID                = model.BuyerID;
                    existcommunication.communicatedBy         = model.communicatedBy;
                    existcommunication.TransferredTo          = model.TransferredTo;
                    existcommunication.IsConverted            = model.IsConverted;
                    existcommunication.Isintersted            = model.Isintersted;
                    existcommunication.CommunicationVia       = model.CommunicationVia;
                    existcommunication.Feedback               = model.Feedback;
                    existcommunication.FirstDateOfInteraction = model.FirstDateOfInteraction;
                    existcommunication.NextFollowUpDate       = model.NextFollowUpDate;
                    existcommunication.NextStep               = model.NextStep;
                    existcommunication.SalesStatus            = model.SalesStatus;


                    _db.SaveChanges();
                    return(Ok(existcommunication));
                }
                else
                {
                    model.CommunicationID = Id++;
                    _db.CommunicationInfos.Add(model);
                    _db.SaveChanges();
                }

                return(Ok(model));
            }
            catch (Exception ex)
            { return(InternalServerError(ex)); }
        }
Esempio n. 9
0
        public void Open()
        {
            VersionInfo        = null;
            CommunicationInfo  = null;
            IdentificationInfo = null;
            Measurements       = null;

            try
            {
                using (StreamReader sr = new StreamReader(this.FilePath, Encoding.UTF7))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (VersionInfo == null && line == "[Version]")
                        {
                            VersionInfo = new VersionInfo();
                        }
                        else if (VersionInfo != null && !VersionInfo.Complete)
                        {
                            VersionInfo.ReadLine(line);
                        }
                        else if (CommunicationInfo == null && line == "[Communication]")
                        {
                            CommunicationInfo = new CommunicationInfo();
                        }
                        else if (CommunicationInfo != null && !CommunicationInfo.Complete)
                        {
                            CommunicationInfo.ReadLine(line);
                        }
                        else if (IdentificationInfo == null && line == "[Identification]")
                        {
                            IdentificationInfo = new IdentificationInfo();
                        }
                        else if (IdentificationInfo != null && !IdentificationInfo.Complete)
                        {
                            IdentificationInfo.ReadLine(line);
                        }
                        else if (Measurements == null && line == "[Measurements]")
                        {
                            Measurements = new Measurements();
                        }
                        else if (Measurements != null && !Measurements.Complete)
                        {
                            Measurements.ReadLine(line);
                        }
                    }
                }
            }
            catch { }

            if (VersionInfo == null)
            {
                VersionInfo = new VersionInfo();
            }
            if (CommunicationInfo == null)
            {
                CommunicationInfo = new CommunicationInfo();
            }
            if (IdentificationInfo == null)
            {
                IdentificationInfo = new IdentificationInfo();
            }
            if (Measurements == null)
            {
                Measurements = new Measurements();
            }
        }
Esempio n. 10
0
        internal void InitializeSession(IdentificationInfo identificationInfo, CommunicationInfo communicationInfo, SessionVariables variables)
        {
            bool idinfostarted    = false,
                 commInfoStarted  = false,
                 variablesStarted = false;

            using (StreamReader sr = new StreamReader(LogFilePath, Encoding.UTF7))
            {
                string line = null;

                while ((line = sr.ReadLine()) != null)
                {
                    if (this.LogType == LogTypes.Unknown)
                    {
                        if (line.Contains("VCDS") || line.Contains("VAG-COM"))
                        {
                            this.LogType = LogTypes.VCDS;
                        }
                        else if (line.StartsWith("Time,"))
                        {
                            this.LogType = LogTypes.Eurodyne;
                        }
                        else if (line.StartsWith("Time (sec),"))
                        {
                            this.LogType = LogTypes.Normal;
                        }
                    }

                    if (this.LogType == LogTypes.VCDS)
                    {
                        if (!variables.Complete)
                        {
                            if (!variablesStarted)
                            {
                                variablesStarted = line.StartsWith(",Group A:") || line.StartsWith("Marker,");
                                NewVCDSFormat    = line.StartsWith("Marker,");
                            }

                            if (variablesStarted)
                            {
                                variables.ReadLine(line, this.LogType);
                            }

                            if (variables.Complete)
                            {
                                break;
                            }
                        }
                    }
                    else if (this.LogType == LogTypes.Eurodyne)
                    {
                        if (!variables.Complete)
                        {
                            if (!variablesStarted)
                            {
                                variablesStarted = line.StartsWith("Time,");
                            }

                            if (variablesStarted)
                            {
                                variables.ReadLine(line, this.LogType);
                            }

                            if (variables.Complete)
                            {
                                break;
                            }
                        }
                    }
                    else if (this.LogType == LogTypes.Normal)
                    {
                        if (!variablesStarted)
                        {
                            variablesStarted = line.StartsWith("Time (sec),");
                        }

                        if (variablesStarted)
                        {
                            variables.ReadLine(line, this.LogType);
                        }

                        if (variables.Complete)
                        {
                            break;
                        }
                    }

                    if (!identificationInfo.Complete)
                    {
                        if (!idinfostarted)
                        {
                            idinfostarted = line.StartsWith("ECU identified with following data:");
                        }
                        else
                        {
                            this.LogType = LogTypes.ME7Logger;
                            identificationInfo.ReadLine(line, true);
                        }
                    }
                    else if (!communicationInfo.Complete)
                    {
                        if (!commInfoStarted)
                        {
                            commInfoStarted = line == "" || line.All(c => c == ',');
                        }
                        else
                        {
                            communicationInfo.ReadLine(line, true);
                        }
                    }
                    else if (!variables.Complete)
                    {
                        if (!variablesStarted)
                        {
                            variablesStarted = line == "" || line.All(c => c == ',');
                        }
                        else
                        {
                            variables.ReadLine(line, this.LogType);
                        }

                        if (variables.Complete)
                        {
                            break;
                        }
                    }
                }
            }
        }