예제 #1
0
 public static void SensorToDocumentString(DocumentString document, Sensor sensor, SensorTrigger trigger)
 {
     document.TriggerValue    = trigger.Value.ToString();
     document.TriggerComparer = trigger.Comparer.ToString();
     document.Id          = sensor.Id.ToString();
     document.FaultState  = sensor.FaultState.ToString();
     document.DeviceState = sensor.DeviceState.ToString();
     document.Value       = sensor.Value.ToString();
     document.Unit        = sensor.Unit;
     document.Value       = sensor.Value.ToString();
     document.DangerHi    = sensor.DangerHi.ToString();
     document.DangerLo    = sensor.DangerLo.ToString();
     document.RangeMax    = sensor.RangeMax.ToString();
     document.RangeMin    = sensor.RangeMin.ToString();
 }
예제 #2
0
        private static async Task <FaultReport> SendFaultReport(Sensor sensor, SensorFault fault, DateTime timestamp)
        {
            if (fault.Type == SensorFaultType.FromTrigger)
            {
                try
                {
                    var trigger = await SensorTriggerAccess.FindSensorTrigger(fault.Id);

                    var template = await FaultReportAccess.FindFaultReportTemplate(trigger.TemplateId);

                    var machine = await MachineAccess.FindMachine(DeviceSettings.ObjectID);

                    var report = new FaultReport
                    {
                        MchCode         = machine.MchCode,
                        MchCodeContract = machine.MchCodeContract,
                        ErrDescr        = template.Directive,
                        ErrDescrLo      = template.FaultDescr,
                        ErrDiscoverCode = template.DiscCode,
                        ErrSymptom      = template.SymptCode,
                        PriorityId      = template.PrioCode,
                        OrgCode         = machine.OrgCode
                    };

                    report = await FaultReportAccess.SetFaultReport(report);

                    DocumentString document = new DocumentString();
                    SensorToDocumentString(document, sensor, trigger);

                    var docFileData = await createDocument(report.WoNo, $"report_{sensor.Id}", document);

                    if (dialogCount == 0)
                    {
                        await ShowDialog(sensor, fault, report, docFileData).ContinueWith(task =>
                        {
                            Interlocked.Decrement(ref dialogCount);
                        });
                    }

                    return(report);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            return(null);
        }
예제 #3
0
        public async Task <IActionResult> Index([Bind("Name, DocumentFile")] DocumentViewModel dvm)
        {
            if (ModelState.IsValid)
            {
                word = dvm.Name;
                var result = string.Empty;

                // Add the document
                Document document = new Document {
                    Word = word
                };
                _db.Documents.Add(document);
                await _db.SaveChangesAsync();

                if (dvm.DocumentFile != null)
                {
                    using (var reader = new StreamReader(dvm.DocumentFile.OpenReadStream()))
                    {
                        result = reader.ReadToEnd();
                    }

                    foreach (string row in result.Split('.'))
                    {
                        if (row.IndexOf(word.ToString()) != -1)
                        {
                            // Add the lines of the document
                            DocumentString documentString = new DocumentString();
                            documentString.DocumentId = _db.Documents.Where(w => w.Word == word).FirstOrDefault().Id;
                            documentString.Count      = WordCounter(row);
                            documentString.Text       = ReverseString(row);
                            _db.DocumentStrings.Add(documentString);
                            await _db.SaveChangesAsync();
                        }
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
예제 #4
0
        public static Task <DocumentFileData> createDocument(int WoN, string title, DocumentString document)
        {
            DocumentFileData file = new DocumentFileData();

            file.DOC_CLASS  = "400";
            file.DOC_FORMAT = "*";
            file.DOC_TYPE   = "ORIGINAL";
            file.TITLE      = title + DateTime.Now.ToString("yyyyMMdd");
            file.LOCAL_PATH = @"\\TriggerReports\TriggerReport";


            file.FILE_DATA = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(document)));

            file.FILE_EXT_ORIGINAL  = "TXT";
            file.ORIGINAL_FILE_NAME = "TriggerReport.txt";
            file.LU_NAME            = "WorkOrder";
            file.KEY_REF            = string.Format("WO_NO={0}^", WoN);
            file.SET_STATE          = "Preliminary".ToUpper();

            var result = cloud.CreateAndCheckInDocument(file);

            return(result);
        }