コード例 #1
0
        void SaveCaptureItems(CaptureItem ci, Event e, DataTable dt)
        {
            string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Capture/Item";
            int    id  = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt);

            adr = adr + "||" + id.ToString("00");

            ci.id = id;

            // Save Root
            string attr = "";

            attr += "id||" + ci.id.ToString("00") + ";";
            attr += "name||" + ci.name.Replace(' ', '_').ToLower() + ";";

            string link = ci.link;
            List <CollectedItem> linkitems = CollectedItems.ToList();
            CollectedItem        dataitem  = linkitems.Find(x => x.Display == link);

            if (dataitem != null)
            {
                link = dataitem.Id;
            }

            attr += "link||" + link + ";";
            DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);
        }
コード例 #2
0
        public void SaveConfiguration(DataTable dt)
        {
            DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt);

            int i = 0;

            foreach (var item in PartCountItems)
            {
                if (!string.IsNullOrEmpty(item.EventName) && !string.IsNullOrEmpty(item.EventValue))
                {
                    string eventPrefix = prefix + "Event||" + i.ToString("00");

                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix, "attributes", "id||" + i.ToString("00") + ";");
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/EventName", "value", item.EventName);
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/EventValue", "value", item.EventValue);
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/PreviousEventValue", "value", item.PreviousEventValue);
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/ValueType", "value", FormatValue(item.ValueType));
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/CaptureItemLink", "value", item.CaptureItemLink);
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/CalculationType", "value", item.CalculationType);
                    DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/StaticIncrementValue", "value", item.StaticIncrementValue.ToString());

                    i++;
                }
            }
        }
コード例 #3
0
        public void SaveConfiguration(DataTable dt)
        {
            // Save Descritpion
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Description", "value", DeviceDescription);

            // Save Type
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "DeviceType", "value", DeviceType);

            // Save Manufacturer
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Manufacturer", "value", Manufacturer);

            // Save Id
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "DeviceId", "value", DeviceId);

            // Save Model
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Model", "value", Model);

            // Save Serial
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Serial", "value", Serial);

            // Save Controller
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Controller", "value", Controller);

            // Save Location
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Location", "value", Location);


            // Save Device Logo
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "LogoUrl", "value", manufacturerLogoFileName);

            // Save Device Image
            DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "ImageUrl", "value", deviceImageFileName);
        }
コード例 #4
0
        public void SaveConfiguration(DataTable dt)
        {
            string prefix = "/GeneratedData/SnapShotData/";

            // Clear all snapshot rows first (so that Ids can be sequentially assigned)
            DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt);

            // Loop through SnapshotItems and add each item back to table with sequential id's
            foreach (var item in SnapshotItems)
            {
                if (item.ParentSnapshot != null)
                {
                    var snapshot = item.ParentSnapshot;

                    if (snapshot.Name != null && snapshot.Link != null)
                    {
                        string adr = "/GeneratedData/SnapShotData/" + String_Functions.UppercaseFirst(snapshot.Type.ToString().ToLower());
                        int    id  = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt);
                        adr = adr + "||" + id.ToString("00");

                        string attr = "";
                        attr += "id||" + id.ToString("00") + ";";
                        attr += "name||" + snapshot.Name + ";";

                        string link = snapshot.Link;

                        attr += "link||" + link + ";";

                        DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);
                    }
                }
            }
        }
コード例 #5
0
        void SaveTrigger(Trigger t, Value v, Event e, DataTable dt, string addressPrefix)
        {
            if (t.link != null && t.modifier != null)
            {
                string adr = addressPrefix + "/Trigger";

                int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt);
                adr = adr + "||" + id.ToString("00");

                t.id = id;

                // Save Root
                string attr = "";
                attr += "id||" + t.id.ToString("00") + ";";

                string link = t.link;
                List <CollectedItem> linkitems = CollectedItems.ToList();
                CollectedItem        dataitem  = linkitems.Find(x => x.Display == link);
                if (dataitem != null)
                {
                    link = dataitem.Id;
                }

                attr += "link||" + link + ";";
                attr += "link_type||" + t.linkType + ";";

                if (t.modifier != null)
                {
                    switch (t.modifier)
                    {
                    case "Not Equal To": attr += "modifier||" + "not" + ";"; break;

                    case "Greater Than": attr += "modifier||" + "greater_than" + ";"; break;

                    case "Less Than": attr += "modifier||" + "less_than" + ";"; break;

                    case "Contains": attr += "modifier||" + "contains" + ";"; break;

                    case "Contains Match Case": attr += "modifier||" + "contains_match_case" + ";"; break;

                    case "Contains Whole Word": attr += "modifier||" + "contains_whole_word" + ";"; break;

                    case "Contains Whole Word Match Case": attr += "modifier||" + "contains_whole_word_match_case" + ";"; break;
                    }
                }

                attr += "value||" + t.value + ";";

                DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);
            }
        }
コード例 #6
0
        void SaveCycleNameLink(DataTable dt)
        {
            string val = null;

            if (SelectedCycleNameLink != null)
            {
                val = SelectedCycleNameLink.ToString();
            }

            if (val != null)
            {
                DataTable_Functions.UpdateTableValue(dt, "address", prefix + "CycleNameLink", "value", val);
            }
        }
コード例 #7
0
        void SaveStoppedEventValueName(DataTable dt)
        {
            string val = "";

            if (SelectedStoppedEventValue != null)
            {
                val = SelectedStoppedEventValue.ToString();
            }

            if (val != null)
            {
                DataTable_Functions.UpdateTableValue(dt, "address", prefix + "StoppedEventValue", "value", val);
            }
        }
コード例 #8
0
        void SaveCycleEventName(DataTable dt)
        {
            string val = "";

            if (SelectedCycleEventName != null)
            {
                val = SelectedCycleEventName.ToString();
            }

            if (val != null)
            {
                DataTable_Functions.UpdateTableValue(dt, "address", prefix + "CycleEventName", "value", val.Replace(' ', '_').ToLower());
            }
        }
コード例 #9
0
        void SaveProductionTypes(DataTable dt)
        {
            foreach (var productionType in ProductionTypes)
            {
                var item = (Controls.ProductionTypeItem)productionType;

                int    id  = DataTable_Functions.TrakHound.GetUnusedAddressId(prefix + "ProductionTypes/Value", dt);
                string adr = prefix + "ProductionTypes/Value||" + id.ToString("00");

                string attr = "";
                attr += "id||" + id.ToString("00") + ";";
                attr += "name||" + item.ValueName + ";";
                attr += "type||" + item.productionType_COMBO.Text + ";";

                DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);
            }
        }
コード例 #10
0
        void SaveEvent(Event e, DataTable dt)
        {
            int    id  = DataTable_Functions.TrakHound.GetUnusedAddressId("/GeneratedData/GeneratedEvents/Event", dt);
            string adr = "/GeneratedData/GeneratedEvents/Event||" + id.ToString("00");

            e.id = id;

            string attr = "";

            attr += "id||" + e.id.ToString("00") + ";";
            attr += "name||" + e.name.Replace(' ', '_').ToLower() + ";";
            attr += "description||" + e.description + ";";

            DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);

            int numval = e.values.Count;

            foreach (Value v in e.values)
            {
                if (v.result != null)
                {
                    v.result.numval = numval;
                    numval         -= 1;
                }
                SaveValue(v, e, dt);
            }

            foreach (CaptureItem ci in e.captureItems)
            {
                SaveCaptureItems(ci, e, dt);
            }

            if (e.Default != null)
            {
                string addr = adr + "/Default";
                attr  = "";
                attr += "numval||" + e.Default.numval.ToString() + ";";
                string val = e.Default.value;

                DataTable_Functions.UpdateTableValue(dt, "address", addr, "attributes", attr);
                DataTable_Functions.UpdateTableValue(dt, "address", addr, "value", val);
            }
        }
コード例 #11
0
        void SaveMultiTrigger(MultiTrigger mt, Value v, Event e, DataTable dt)
        {
            string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00");

            adr += "/Value||" + v.id.ToString("00") + "/Triggers";
            adr += "/MultiTrigger";

            int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt);

            adr = adr + "||" + id.ToString("00");

            // Set Attributes
            string attr = "";

            attr += "id||" + id.ToString("00") + ";";

            DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);

            foreach (var trigger in mt.triggers)
            {
                SaveTrigger(trigger, v, e, dt, adr);
            }
        }
コード例 #12
0
        private void Save_Worker(object o)
        {
            bool success = false;

            var dt = (DataTable)o;

            if (dt != null)
            {
                // Reset Update ID
                DataTable_Functions.UpdateTableValue(dt, "address", "/UpdateId", "value", Guid.NewGuid().ToString());

                if (userConfig != null)
                {
                    success = Devices.Update(userConfig, dt);
                }
                // If not logged in Save to File in 'C:\TrakHound\'
                else
                {
                    success = DeviceConfiguration.Save(dt);
                }

                if (success)
                {
                    XmlDocument xml = DeviceConfiguration.TableToXml(dt);
                    if (xml != null)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Configuration      = DeviceConfiguration.Read(xml);
                            ConfigurationTable = dt.Copy();
                        }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
                    }
                }
            }

            Dispatcher.BeginInvoke(new Action <bool>(Save_Finished), System.Windows.Threading.DispatcherPriority.Background, new object[] { success });
        }
コード例 #13
0
        public void SaveConfiguration(DataTable dt)
        {
            // Remove old rows
            DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt);

            // Save IP Address
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Address", "value", Address);

            // Save Port
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Port", "value", Port);

            // Save Device Name
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "DeviceName", "value", DeviceName);

            // Save Heartbeat
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Heartbeat", "value", Heartbeat.ToString());


            // Save Proxy Address
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "ProxyAddress", "value", ProxyAddress);

            // Save Proxy Port
            DataTable_Functions.UpdateTableValue(dt, "address", prefix + "ProxyPort", "value", ProxyPort);
        }
コード例 #14
0
        void SaveValue(Value v, Event e, DataTable dt)
        {
            int    id  = DataTable_Functions.TrakHound.GetUnusedAddressId("/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Value", dt);
            string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Value||" + id.ToString("00");

            v.id = id;

            // Save Root
            string attr = "";

            attr += "id||" + v.id.ToString("00") + ";";
            DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr);

            // Save Triggers
            foreach (Trigger t in v.triggers.OfType <Trigger>())
            {
                SaveTrigger(t, v, e, dt);
            }

            // Save MultiTriggers
            foreach (MultiTrigger mt in v.triggers.OfType <MultiTrigger>())
            {
                SaveMultiTrigger(mt, v, e, dt);
            }

            // Save Result
            if (v.result != null)
            {
                string addr = adr + "/Result";
                attr  = "";
                attr += "numval||" + v.result.numval.ToString() + ";";
                string val = v.result.value;
                DataTable_Functions.UpdateTableValue(dt, "address", addr, "attributes", attr);
                DataTable_Functions.UpdateTableValue(dt, "address", addr, "value", val);
            }
        }
コード例 #15
0
 public static void EditTable(DataTable table, string address, object value, string attributes)
 {
     DataTable_Functions.UpdateTableValue(table, "address", address, "value", value == null ? string.Empty : value.ToString());
     DataTable_Functions.UpdateTableValue(table, "address", address, "attributes", attributes);
 }