Beispiel #1
0
 protected Vehicles(ModelName modelName)
 {
     this.modelName = modelName;
     this.modelName = modelName;
 }
Beispiel #2
0
 protected HMMWV(ModelName modelName) : base(ModelName.HMMWV, 4, 4)
 {
 }
Beispiel #3
0
        public override string this[string columnName]
        {
            get
            {
                var field = (FieldNames)Enum.Parse(typeof(FieldNames), columnName);
                switch (field)
                {
                case FieldNames.Inventory:
                    ClearErrors(columnName);
                    CheckSalePrice(columnName);
                    if (SalePrice < 0)
                    {
                        AddError("Inventory can not be less than zero", columnName);
                    }
                    CheckSalePrice(FieldNames.SalePrice.ToString());

                    break;

                case FieldNames.ModelName:
                    if (ModelName.Contains("XXX"))
                    {
                        var errors = new List <string>()
                        {
                            "Our Store does not support adult content."
                        };
                        SetErrors(errors, columnName);
                    }
                    else
                    {
                        ClearErrors(columnName);
                    }
                    break;

                case FieldNames.Price:
                    if (Price < 0)
                    {
                        var errors = new List <string>()
                        {
                            "Price can not be less than zero"
                        };
                        SetErrors(errors, columnName);
                    }
                    else
                    {
                        ClearErrors(columnName);
                    }
                    break;

                case FieldNames.SalePrice:
                    ClearErrors(columnName);
                    CheckSalePrice(columnName);
                    if (SalePrice < 0)
                    {
                        AddError("Sale Price can not be less than zero", columnName);
                    }
                    CheckSalePrice(FieldNames.Inventory.ToString());
                    break;

                default:
                    break;
                }
                return(string.Empty);
            }
        }
Beispiel #4
0
 protected Vehicles(ModelName modelName, int numOfWheels, int numOfSeats)
 {
     this.modelName   = modelName;
     this.numOfWheels = numOfWheels;
     this.numOfSeats  = numOfSeats;
 }
Beispiel #5
0
        public string GenerateReactView(string name)
        {
            var rv = GetResource($"{name}.txt", "Spa.React.views")
                     .Replace("$modelname$", ModelName.ToLower());
            Type modelType = Type.GetType(SelectedModel);

            if (name == "table")
            {
                StringBuilder fieldstr = new StringBuilder();
                var           pros     = FieldInfos.Where(x => x.IsListField == true).ToList();
                fieldstr.Append(Environment.NewLine);
                for (int i = 0; i < pros.Count; i++)
                {
                    var    item   = pros[i];
                    string label  = modelType.GetProperty(item.FieldName).GetPropertyDisplayName();
                    string render = "columnsRender";
                    if (string.IsNullOrEmpty(item.RelatedField) == false)
                    {
                        var subtype = Type.GetType(item.RelatedField);
                        if (subtype == typeof(FileAttachment))
                        {
                            render = "columnsRenderImg";
                        }
                    }
                    fieldstr.Append($@"{{
        dataIndex: ""{item.FieldName}"",
        title: ""{label}"",
        render: {render} 
    }}");
                    if (i < pros.Count - 1)
                    {
                        fieldstr.Append(",");
                    }
                    fieldstr.Append(Environment.NewLine);
                }
                return(rv.Replace("$columns$", fieldstr.ToString()));
            }
            if (name == "models")
            {
                StringBuilder fieldstr = new StringBuilder();
                var           pros     = FieldInfos.Where(x => x.IsFormField == true).ToList();

                for (int i = 0; i < pros.Count; i++)
                {
                    var    item  = pros[i];
                    string label = modelType.GetProperty(item.FieldName).GetPropertyDisplayName();
                    if (string.IsNullOrEmpty(item.RelatedField) == false)
                    {
                        var subtype = Type.GetType(item.RelatedField);
                        if (item.SubField == "`file")
                        {
                            fieldstr.Append($@"{item.FieldName}: <UploadImg />");
                        }
                        else
                        {
                            fieldstr.Append($@"{item.FieldName}: <Select placeholder=""{label}"" showArrow allowClear></Select>");
                        }
                    }
                    else
                    {
                        var  proType   = modelType.GetProperty(item.FieldName).PropertyType;
                        Type checktype = proType;
                        if (proType.IsNullable())
                        {
                            checktype = proType.GetGenericArguments()[0];
                        }
                        if (checktype == typeof(bool) || checktype.IsEnum())
                        {
                            fieldstr.Append($@"{item.FieldName}: <Switch checkedChildren={{<Icon type=""check"" />}} unCheckedChildren={{<Icon type=""close"" />}} />");
                        }
                        else if (checktype.IsPrimitive || checktype == typeof(string))
                        {
                            fieldstr.Append($@"{item.FieldName}: <Input placeholder=""请输入 {label}"" />");
                        }
                        else if (checktype == typeof(DateTime))
                        {
                            fieldstr.Append($@"{item.FieldName}: <Input placeholder=""请输入 {label}"" />");
                        }
                    }
                    if (i < pros.Count - 1)
                    {
                        fieldstr.Append(",");
                    }
                    fieldstr.Append(Environment.NewLine);
                }
                return(rv.Replace("$fields$", fieldstr.ToString()));
            }

            if (name == "search")
            {
                StringBuilder fieldstr = new StringBuilder();
                var           pros     = FieldInfos.Where(x => x.IsSearcherField == true).ToList();

                for (int i = 0; i < pros.Count; i++)
                {
                    var    item  = pros[i];
                    string label = modelType.GetProperty(item.FieldName).GetPropertyDisplayName();

                    fieldstr.Append($@"
<Form.Item label=""{label}"" {{...formItemLayout}}>
    {{getFieldDecorator('{item.FieldName}', {{
        initialValue: Store.searchParams['{item.FieldName}']
    }})(Models.{item.FieldName})}}
</Form.Item>
");
                    fieldstr.Append(Environment.NewLine);
                }
                return(rv.Replace("$fields$", fieldstr.ToString()));
            }
            if (name == "details")
            {
                StringBuilder addfield    = new StringBuilder();
                StringBuilder editfield   = new StringBuilder();
                StringBuilder detailfield = new StringBuilder();
                var           pros        = FieldInfos.Where(x => x.IsFormField == true).ToList();

                for (int i = 0; i < pros.Count; i++)
                {
                    var    item       = pros[i];
                    var    property   = modelType.GetProperty(item.FieldName);
                    string label      = property.GetPropertyDisplayName();
                    bool   isrequired = property.IsPropertyRequired();
                    string rules      = "rules: []";
                    if (isrequired == true)
                    {
                        rules = $@"rules: [{{ ""required"": true, ""message"": ""{label}不能为空"" }}]";
                    }

                    if (string.IsNullOrEmpty(item.RelatedField) == false && item.SubField == "`file")
                    {
                        addfield.Append($@"
<InfoShellCol span={{24}}>
    <Form.Item label=""{label}""  {{...formItemLayoutRow}}>
        {{getFieldDecorator('{item.FieldName}', {{

        }})(Models.{item.FieldName})}}
    </Form.Item >
</InfoShellCol>
");
                        editfield.Append($@"
<InfoShellCol span={{24}}>
    <Form.Item label=""{label}""  {{...formItemLayoutRow}}>
        {{getFieldDecorator('{item.FieldName}', {{
            initialValue: details['{item.FieldName}']
        }})(Models.{item.FieldName})}}
    </Form.Item >
</InfoShellCol>
");
                        detailfield.Append($@"
<InfoShellCol span={{24}}>
    <Form.Item label=""{label}""  {{...formItemLayoutRow}}>
        <span>
            <ToImg fileID={{details['{item.FieldName}']}} />
        </span>
    </Form.Item >
</InfoShellCol>
");
                    }
                    else
                    {
                        addfield.Append($@"
<Form.Item label=""{label}"" {{...formItemLayout}}>
    {{getFieldDecorator('{item.FieldName}', {{
        {rules}
    }})(Models.{item.FieldName})}}
</Form.Item>
");

                        editfield.Append($@"
<Form.Item label=""{label}"" {{...formItemLayout}}>
    {{getFieldDecorator('{item.FieldName}', {{
        {rules},
        initialValue: toValues(details['{item.FieldName}'])
    }})(Models.{item.FieldName})}}
</Form.Item>
");

                        detailfield.Append($@"
<Form.Item label=""{label}"" {{...formItemLayout}}>
    <span>{{toValues(details['{item.FieldName}'], ""span"")}}</span>
</Form.Item>
");
                    }
                    addfield.Append(Environment.NewLine);
                    editfield.Append(Environment.NewLine);
                    detailfield.Append(Environment.NewLine);
                }
                return(rv.Replace("$addfields$", addfield.ToString()).Replace("$editfields$", editfield.ToString()).Replace("$detailfields$", detailfield.ToString()));
            }

            return(rv);
        }
Beispiel #6
0
 // needs to be changed -> method injection
 public void PlaceOrder(ModelName modelName)
 {
     switch (modelName)
     {
         case ModelName.BMW520:
             this.PlaceOrder(modelName, 50000.0, 1);
             break;
         case ModelName.BMW320:
             this.PlaceOrder(modelName, 45000.0, 1);
             break;
         case ModelName.BMW235:
             this.PlaceOrder(modelName, 30000.0, 1);
             break;
         case ModelName.HondaCruiser:
             this.PlaceOrder(modelName, 25000.0, 1);
             break;
         case ModelName.HondaSport:
             this.PlaceOrder(modelName, 20000.0, 1);
             break;
         case ModelName.HondaTouring:
             this.PlaceOrder(modelName, 15000.0, 1);
             break;
         default:
             break;
     }
 }
Beispiel #7
0
        static void HandleElapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            System.Collections.Generic.Dictionary <string, string> dConfig = new System.Collections.Generic.Dictionary <string, string> ();

            if (!System.IO.Directory.Exists("dyndata"))
            {
                System.IO.Directory.CreateDirectory("dyndata");
            }

            bool Enable = false; string ConnectionStatus = "Unbekannt"; string PossibleConnectionTypes = "Unbekannt"; string ConnectionType = "Unbekannt"; string Name = "Unbekannt"; uint Uptime = 0; uint UpstreamMaxBitRate = 0; uint DownstreamMaxBitRate = 0; string LastConnectionError = ""; uint IdleDisconnectTime = 0; bool RSIPAvailable = false; string UserName = "******"; bool NATEnabled = false; string ExternalIPAddress = "0.0.0.0"; string DNSServers = "0.0.0.0"; string MACAddress = "::::"; string ConnectionTrigger = "Unbekannt"; string LastAuthErrorInfo = ""; ushort MaxCharsUsername = 0; ushort MinCharsUsername = 0; string AllowedCharsUsername = "******"; ushort MaxCharsPassword = 0; ushort MinCharsPassword = 0; string AllowedCharsPassword = "******"; string TransportType = "Unbekannt"; string RouteProtocolRx = "Unbekannt"; string PPPoEServiceName = "Unbekannt"; string RemoteIPAddress = "0.0.0.0"; string PPPoEACName = "Unbekannt"; bool DNSEnabled = false; bool DNSOverrideAllowed = false;

            try {
                Wanpppconn1 service = new Wanpppconn1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
                service.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
                service.GetInfo(out Enable, out ConnectionStatus, out PossibleConnectionTypes, out ConnectionType, out Name, out Uptime, out UpstreamMaxBitRate, out DownstreamMaxBitRate, out LastConnectionError, out IdleDisconnectTime, out RSIPAvailable, out UserName, out NATEnabled, out ExternalIPAddress, out DNSServers, out MACAddress, out ConnectionTrigger, out LastAuthErrorInfo, out MaxCharsUsername, out MinCharsUsername, out AllowedCharsUsername, out MaxCharsPassword, out MinCharsPassword, out AllowedCharsPassword, out TransportType, out RouteProtocolRx, out PPPoEServiceName, out RemoteIPAddress, out PPPoEACName, out DNSEnabled, out DNSOverrideAllowed);
                dConfig.Clear();
                dConfig.Add("Enable", Enable.ToString());
                dConfig.Add("ConnectionStatus", ConnectionStatus.ToString());
                dConfig.Add("PossibleConnectionTypes", PossibleConnectionTypes.ToString());
                dConfig.Add("ConnectionType", ConnectionType.ToString());
                dConfig.Add("Name", Name.ToString());
                dConfig.Add("Uptime", System.DateTime.Now.AddSeconds(Uptime).ToString());
                dConfig.Add("UpstreamMaxBitRate", UpstreamMaxBitRate.ToString());
                dConfig.Add("DownstreamMaxBitRate", DownstreamMaxBitRate.ToString());
                dConfig.Add("LastConnectionError", LastConnectionError.ToString());
                dConfig.Add("IdleDisconnectTime", IdleDisconnectTime.ToString());
                dConfig.Add("RSIPAvailable", RSIPAvailable.ToString());
                dConfig.Add("UserName", UserName.ToString());
                dConfig.Add("NATEnabled", NATEnabled.ToString());
                dConfig.Add("ExternalIPAddress", ExternalIPAddress.ToString());
                dConfig.Add("DNSServers", DNSServers.ToString());
                dConfig.Add("MACAddress", MACAddress.ToString());
                dConfig.Add("ConnectionTrigger", ConnectionTrigger.ToString());
                dConfig.Add("LastAuthErrorInfo", LastAuthErrorInfo.ToString());
                dConfig.Add("MaxCharsUsername", MaxCharsUsername.ToString());
                dConfig.Add("MinCharsUsername", MinCharsUsername.ToString());
                dConfig.Add("AllowedCharsUsername", AllowedCharsUsername.ToString());
                dConfig.Add("MaxCharsPassword", MaxCharsPassword.ToString());
                dConfig.Add("MinCharsPassword", MinCharsPassword.ToString());
                dConfig.Add("AllowedCharsPassword", AllowedCharsPassword.ToString());
                dConfig.Add("TransportType", TransportType.ToString());
                dConfig.Add("RouteProtocolRx", RouteProtocolRx.ToString());
                dConfig.Add("PPPoEServiceName", PPPoEServiceName.ToString());
                dConfig.Add("RemoteIPAddress", RemoteIPAddress.ToString());
                dConfig.Add("PPPoEACName", PPPoEACName.ToString());
                dConfig.Add("DNSEnabled", DNSEnabled.ToString());
                dConfig.Add("DNSOverrideAllowed", DNSOverrideAllowed.ToString());
                FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wanppp.info");
            } catch (Exception ex) {
                FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex));
            }



            System.Net.WebClient WC = new WebClient();

            FritzTR064.Generated.Tam cTam = new Tam("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            cTam.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            string TamList;

            for (ushort i = 0; i < 5; i++)
            {
                ushort Index;
                bool   abEnable;
                string abName;
                bool   TAMRunning;
                ushort Stick;
                ushort Status;
                cTam.GetInfo(i, out abEnable, out abName, out TAMRunning, out Stick, out Status);
                dConfig.Clear();
                dConfig.Add("Enable", abEnable.ToString());
                dConfig.Add("Name", abName.ToString());
                dConfig.Add("TAMRunning", TAMRunning.ToString());
                dConfig.Add("Stick", Stick.ToString());
                dConfig.Add("Status", Status.ToString());
                if (abEnable == true)
                {
                    cTam.GetMessageList(i, out TamList);
                    WC.Credentials = cTam.SoapHttpClientProtocol.Credentials;
                    WC.DownloadFile(TamList, "dyndata/tam" + i.ToString() + ".xml");
                }
                FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/tam.info");
            }


            FritzTR064.Generated.Contact c = new Contact("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            c.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            string calllist; string DectIDList; string HandsetName; ushort PhonebookID;  bool cEnable; string cStatus; string LastConnect; string Url; string ServiceId; string Username;

            dConfig.Clear();
            c.GetCallList(out calllist);
            WC.Credentials = c.SoapHttpClientProtocol.Credentials;
            WC.DownloadFile(calllist, "dyndata/calllist.xml");
            try {
                c.GetInfo(out cEnable, out cStatus, out LastConnect, out Url, out ServiceId, out UserName, out Name);
                dConfig.Add("Enable", cEnable.ToString());
                dConfig.Add("Status", cStatus.ToString());
                dConfig.Add("LastConnect", LastConnect.ToString());
                dConfig.Add("Url", Url.ToString());
                dConfig.Add("ServiceId", ServiceId.ToString());
                dConfig.Add("Name", Name.ToString());
                if (cEnable)
                {
                    c.GetDECTHandsetList(out DectIDList);
                    for (ushort DectID = 1; DectID < 10; DectID++)
                    {
                        c.GetDECTHandsetInfo(DectID, out HandsetName, out PhonebookID);
                        dConfig.Add("DectID", DectID.ToString());
                        dConfig.Add("HandsetName-" + DectID.ToString(), HandsetName.ToString());
                        dConfig.Add("PhonebookID-" + DectID.ToString(), PhonebookID.ToString());
                    }
                }
                //			c.GetInfoByIndex();
                //			c.GetNumberOfEntries();
                //			c.GetPhonebook();
                //			c.GetPhonebookList();
            } catch (Exception ex) {
                FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex));
            }


            FritzTR064.Generated.Wandslifconfig1 w1 = new Wandslifconfig1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            w1.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            //FritzTR064.Generated.Wandsllinkconfig1 w2 = new Wandsllinkconfig1(());
            bool wandslIFEnable; string dslStatus; string DataPath; uint UpstreamCurrRate; uint DownstreamCurrRate; uint UpstreamMaxRate; uint DownstreamMaxRate; uint UpstreamNoiseMargin; uint DownstreamNoiseMargin; uint UpstreamAttenuation; uint DownstreamAttenuation; string ATURVendor; string ATURCountry; ushort UpstreamPower; ushort DownstreamPower;

            w1.GetInfo(out wandslIFEnable, out dslStatus, out DataPath, out UpstreamCurrRate, out DownstreamCurrRate, out UpstreamMaxRate, out DownstreamMaxRate, out UpstreamNoiseMargin, out DownstreamNoiseMargin, out UpstreamAttenuation, out DownstreamAttenuation, out ATURVendor, out ATURCountry, out UpstreamPower, out DownstreamPower);
            dConfig.Clear();
            dConfig.Add("wandslIFEnable", wandslIFEnable.ToString());
            dConfig.Add("Status", dslStatus.ToString());
            dConfig.Add("DataPath", DataPath.ToString());
            dConfig.Add("UpstreamCurrRate", UpstreamCurrRate.ToString());
            dConfig.Add("DownstreamCurrRate", DownstreamCurrRate.ToString());
            dConfig.Add("UpstreamMaxRate", UpstreamMaxRate.ToString());
            dConfig.Add("DownstreamMaxRate", DownstreamMaxRate.ToString());
            dConfig.Add("UpstreamNoiseMargin", UpstreamNoiseMargin.ToString());
            dConfig.Add("DownstreamNoiseMargin", DownstreamNoiseMargin.ToString());
            dConfig.Add("UpstreamAttenuation", UpstreamAttenuation.ToString());
            dConfig.Add("DownstreamAttenuation", DownstreamAttenuation.ToString());
            dConfig.Add("ATURVendor", ATURVendor.ToString());
            dConfig.Add("ATURCountry", ATURCountry.ToString());
            dConfig.Add("UpstreamPower", UpstreamPower.ToString());
            dConfig.Add("DownstreamPower", DownstreamPower.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wandsl.info");

            FritzTR064.Generated.Wlanconfig1 wlc = new Wlanconfig1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            wlc.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            string wlStatus; bool wlEnable; string MaxBitRate; byte Channel; string SSID; string BeaconType; bool MACAddressControlEnabled; string Standard; string BSSID; string BasicEncryptionModes; string BasicAuthenticationMode; byte MaxCharsSSID; byte MinCharsSSID; string AllowedCharsSSID; byte MinCharsPSK; byte MaxCharsPSK; string AllowedCharsPSK;

            wlc.GetInfo(out wlEnable, out wlStatus, out MaxBitRate, out Channel, out SSID, out BeaconType, out MACAddressControlEnabled, out Standard, out BSSID, out BasicEncryptionModes, out BasicAuthenticationMode, out MaxCharsSSID, out MinCharsSSID, out AllowedCharsSSID, out MinCharsPSK, out MaxCharsPSK, out AllowedCharsPSK);
            dConfig.Clear();
            dConfig.Add("Enable", wlEnable.ToString());
            dConfig.Add("Status", wlStatus.ToString());
            dConfig.Add("MaxBitRate", MaxBitRate.ToString());
            dConfig.Add("Channel", Channel.ToString());
            dConfig.Add("SSID", SSID.ToString());
            dConfig.Add("BeaconType", BeaconType.ToString());
            dConfig.Add("MACAddressControlEnabled", MACAddressControlEnabled.ToString());
            dConfig.Add("Standard", Standard.ToString());
            dConfig.Add("BSSID", BSSID.ToString());
            dConfig.Add("BasicEncryptionModes", BasicEncryptionModes.ToString());
            dConfig.Add("BasicAuthenticationMode", BasicAuthenticationMode.ToString());
            dConfig.Add("MaxCharsSSID", MaxCharsSSID.ToString());
            dConfig.Add("MinCharsSSID", MinCharsSSID.ToString());
            dConfig.Add("AllowedCharsSSID", AllowedCharsSSID.ToString());
            dConfig.Add("MinCharsPSK", MinCharsPSK.ToString());
            dConfig.Add("MaxCharsPSK", MaxCharsPSK.ToString());
            dConfig.Add("AllowedCharsPSK", AllowedCharsPSK.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wlan.info");

            FritzTR064.Generated.Voip voip1 = new Voip("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            voip1.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            string NumberList; bool FaxT38Enable; string VoiceCoding; string ClientList; ushort ExistingVoIPNumbers; string PhoneName; uint NumberOfNumbers; ushort NumberOfClients; ushort MaxVoipNumbers;

            voip1.GetInfo(out FaxT38Enable, out VoiceCoding);
            voip1.GetClients(out ClientList);
            voip1.GetExistingVoIPNumbers(out ExistingVoIPNumbers);
            voip1.DialGetConfig(out PhoneName);
            voip1.GetNumbers(out NumberList);
            voip1.GetNumberOfNumbers(out NumberOfNumbers);
            voip1.GetNumberOfClients(out NumberOfClients);
            voip1.GetMaxVoIPNumbers(out MaxVoipNumbers);
            dConfig.Clear();
            dConfig.Add("NumberList", NumberList.ToString());
            dConfig.Add("FaxT38Enable", FaxT38Enable.ToString());
            dConfig.Add("VoiceCoding", VoiceCoding.ToString());
            dConfig.Add("ClientList", ClientList.ToString());
            dConfig.Add("ExistingVoIPNumbers", ExistingVoIPNumbers.ToString());
            dConfig.Add("PhoneName", PhoneName.ToString());
            dConfig.Add("NumberOfNumbers", NumberOfNumbers.ToString());
            dConfig.Add("NumberOfClients", NumberOfClients.ToString());
            dConfig.Add("MaxVoipNumbers", MaxVoipNumbers.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/phone.info");

            string ManufacturerName; string ManufacturerOUI; string ModelName; string Description; string ProductClass; string SerialNumber; string SoftwareVersion; string HardwareVersion; string SpecVersion; string ProvisioningCode; uint UpTime; string DeviceLog;

            FritzTR064.Generated.Deviceinfo DevInfo = new Deviceinfo("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]);
            DevInfo.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]);
            DevInfo.GetInfo(out ManufacturerName, out ManufacturerOUI, out ModelName, out Description, out ProductClass, out SerialNumber, out SoftwareVersion, out HardwareVersion, out SpecVersion, out ProvisioningCode, out UpTime, out DeviceLog);
            dConfig.Clear();
            dConfig.Add("ManufacturerName", ManufacturerName.ToString());
            dConfig.Add("ManufacturerOUI", ManufacturerOUI.ToString());
            dConfig.Add("ModelName", ModelName.ToString());
            dConfig.Add("Description", Description.ToString());
            dConfig.Add("ProductClass", ProductClass.ToString());
            dConfig.Add("SerialNumber", SerialNumber.ToString());
            dConfig.Add("SoftwareVersion", SoftwareVersion.ToString());
            dConfig.Add("HardwareVersion", HardwareVersion.ToString());
            dConfig.Add("SpecVersion", SpecVersion.ToString());
            dConfig.Add("ProvisioningCode", ProvisioningCode.ToString());
            dConfig.Add("UpTime", UpTime.ToString());
            dConfig.Add("DeviceLog", DeviceLog.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/DeviceInfo.info");


            //FritzTR064.Generated.Contact

            //dConfig.Add("",xxxxxx.ToString());


            System.Diagnostics.Process P;

            P = new System.Diagnostics.Process()
            {
                StartInfo =
                {
                    FileName               = NetConfig ["fing"],
                    Arguments              = " -n " + NetConfig ["Gateway"] + "/24 -r 1 --session " + System.IO.Path.Combine(System.Environment.CurrentDirectory, "network.fing") + " -o table,csv," + System.IO.Path.Combine(System.Environment.CurrentDirectory, "network.csv"),
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true
                }
            };
            P.Start();
            P.WaitForExit(10000);


            P = new System.Diagnostics.Process()
            {
                StartInfo =
                {
                    FileName               = "/usr/local/bin/lsusb",
                    WorkingDirectory       = "/tmp/",
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true
                }
            };
            P.Start();
            string lsusb    = P.StandardOutput.ReadToEnd();
            int    USBCount = lsusb.Split(new [] { "\n" }, StringSplitOptions.RemoveEmptyEntries).Length;

            P.WaitForExit(10000);
            dConfig.Clear();
            dConfig.Add("Count", USBCount.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/usb.info");

            P = new System.Diagnostics.Process()
            {
                StartInfo =
                {
                    FileName               = "/Users/systemiya-apple/i2cdetect.sh",
                    WorkingDirectory       = "/tmp/",
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true
                }
            };
            P.Start();
            string lsi2c = P.StandardOutput.ReadToEnd();

            P.WaitForExit(10000);
            dConfig.Clear();
            string[] i2C      = lsi2c.Split(new [] { "--" }, StringSplitOptions.RemoveEmptyEntries);
            int      I2Ccount = 116 - (i2C.Length - 2);

            dConfig.Add("Count", I2Ccount.ToString());
            FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/i2c.info");
        }
        public void SetNodeGainORDamageTest()
        {
            ModelName   mn = new ModelName();
            ModelWeight mw = new ModelWeight();

            ModelNode[] l1n = new ModelNode[ModelLink.LEVEL1_UNITNUM];
            ModelNode[] l2n = new ModelNode[ModelLink.LEVEL2_UNITNUM];
            ModelNode[] l3n = new ModelNode[ModelLink.LEVEL3_UNITNUM];
            ModelNode[] l4n = new ModelNode[ModelLink.LEVEL4_UNITNUM];
            for (int i = 0; i < ModelLink.LEVEL1_UNITNUM; i++)
            {
                l1n[i] = new ModelNode();
            }
            for (int i = 0; i < ModelLink.LEVEL2_UNITNUM; i++)
            {
                l2n[i] = new ModelNode();
            }
            for (int i = 0; i < ModelLink.LEVEL3_UNITNUM; i++)
            {
                l3n[i] = new ModelNode();
            }
            for (int i = 0; i < ModelLink.LEVEL4_UNITNUM; i++)
            {
                l4n[i] = new ModelNode();
            }

            mn.SetNodeName(l1n[0], ModelName.LEVELNAME_QUALITYATTRIBUTE_1);
            mn.SetNodeName(l2n[0], ModelName.LEVELNAME_ATTRIBUTE_1);
            mn.SetNodeName(l2n[1], ModelName.LEVELNAME_ATTRIBUTE_2);
            mn.SetNodeName(l2n[2], ModelName.LEVELNAME_ATTRIBUTE_3);
            mn.SetNodeName(l2n[3], ModelName.LEVELNAME_ATTRIBUTE_4);
            mn.SetNodeName(l3n[0], ModelName.LEVELNAME_PROPERTY_1);
            mn.SetNodeName(l3n[1], ModelName.LEVELNAME_PROPERTY_2);
            mn.SetNodeName(l3n[2], ModelName.LEVELNAME_PROPERTY_3);
            mn.SetNodeName(l3n[3], ModelName.LEVELNAME_PROPERTY_4);
            mn.SetNodeName(l3n[4], ModelName.LEVELNAME_PROPERTY_5);
            mn.SetNodeName(l3n[5], ModelName.LEVELNAME_PROPERTY_6);
            mn.SetNodeName(l3n[6], ModelName.LEVELNAME_PROPERTY_7);
            mn.SetNodeName(l4n[0], ModelName.LEVELNAME_METRIC_1);
            mn.SetNodeName(l4n[1], ModelName.LEVELNAME_METRIC_2);
            mn.SetNodeName(l4n[2], ModelName.LEVELNAME_METRIC_3);
            mn.SetNodeName(l4n[3], ModelName.LEVELNAME_METRIC_4);
            mn.SetNodeName(l4n[4], ModelName.LEVELNAME_METRIC_5);
            mn.SetNodeName(l4n[5], ModelName.LEVELNAME_METRIC_6);
            mn.SetNodeName(l4n[6], ModelName.LEVELNAME_METRIC_7);
            mn.SetNodeName(l4n[7], ModelName.LEVELNAME_METRIC_8);

            for (int i = 0; i < ModelLink.LEVEL1_UNITNUM; i++)
            {
                mw.SetNodeGainORDamage(l1n[i]);
            }
            for (int i = 0; i < ModelLink.LEVEL2_UNITNUM; i++)
            {
                mw.SetNodeGainORDamage(l2n[i]);
            }
            for (int i = 0; i < ModelLink.LEVEL3_UNITNUM; i++)
            {
                mw.SetNodeGainORDamage(l3n[i]);
            }
            for (int i = 0; i < ModelLink.LEVEL4_UNITNUM; i++)
            {
                mw.SetNodeGainORDamage(l4n[i]);
            }

            int result;

            for (int i = 0; i < ModelLink.LEVEL1_UNITNUM; i++)
            {
                mw.node_affect_dictionary.TryGetValue(l1n[i].NodeName, out result);
                Assert.AreEqual(result, l1n[i].gain_or_damage);
            }
            for (int i = 0; i < ModelLink.LEVEL2_UNITNUM; i++)
            {
                mw.node_affect_dictionary.TryGetValue(l2n[i].NodeName, out result);
                Assert.AreEqual(result, l2n[i].gain_or_damage);
            }
            for (int i = 0; i < ModelLink.LEVEL3_UNITNUM; i++)
            {
                mw.node_affect_dictionary.TryGetValue(l3n[i].NodeName, out result);
                Assert.AreEqual(result, l3n[i].gain_or_damage);
            }
            for (int i = 0; i < ModelLink.LEVEL4_UNITNUM; i++)
            {
                mw.node_affect_dictionary.TryGetValue(l4n[i].NodeName, out result);
                Assert.AreEqual(result, l4n[i].gain_or_damage);
            }
        }
Beispiel #9
0
 public override string Log() => $"{Location.PadRight(20)}{Category.PadRight(15)}{ProdName.PadRight(15)}{ModelName.PadRight(8)}{PurchaseDate.ToShortDateString().PadRight(8)}\t{Price.ToString().PadRight(10)}{CurrencyFormat.PadLeft(10)}";
        public ActionResult <ServiceResponse> Post([Bind("Url")][FromBody] ServiceRequest request)
        {
            // Boilerpipe.net code below
            string html     = "";
            string headline = "";
            string source   = "";
            string text     = "";
            string img      = "";

            try
            {
                if (Uri.IsWellFormedUriString(request.Url, UriKind.Absolute))
                {
                    using (WebClient webClient = new WebClient())
                    {
                        html = webClient.DownloadString(request.Url);
                    }
                    text     = RemoveSpecialCharacters(CommonExtractors.LargestContentExtractor.GetText(html));
                    headline = RemoveSpecialCharacters(Regex.Match(html, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>",
                                                                   RegexOptions.IgnoreCase).Groups["Title"].Value);

                    var domainParser = new DomainParser(new WebTldRuleProvider());
                    var domainName   = domainParser.Get(request.Url);
                    source = domainName.RegistrableDomain;

                    img = "http://" + FetchLinksFromSource(html)[0].AbsolutePath;
                }
                else
                {
                    return(BadRequest(new ServiceResponse
                    {
                        Success = false,
                        Error = "Bad URL."
                    }));
                }

                // Google Cloud API code below
                var credential = GoogleCredential.FromJson(ServiceAccountJSON)
                                 .CreateScoped(LanguageServiceClient.DefaultScopes);
                var channel = new Grpc.Core.Channel(
                    AutoMlClient.DefaultEndpoint.ToString(),
                    credential.ToChannelCredentials());
                PredictionServiceClient client = PredictionServiceClient.Create(channel);

                string modelFullId = ModelName.Format("partem-1579924523879", "us-central1", "TCN7494917767758348288");

                PredictRequest predictRequest = new PredictRequest
                {
                    Name    = modelFullId,
                    Payload = new ExamplePayload
                    {
                        TextSnippet = new TextSnippet
                        {
                            Content  = text,
                            MimeType = "text/plain"
                        }
                    }
                };

                PredictResponse response = client.Predict(predictRequest);

                var leftPerc  = response.Payload.First(x => x.DisplayName == "left").Classification.Score;
                var rightPerc = response.Payload.First(x => x.DisplayName == "right").Classification.Score;
                return(Ok(new ServiceResponse
                {
                    LeftPercentage = leftPerc,
                    RightPercentage = rightPerc,
                    CenterPercentage = 1 - Math.Abs(leftPerc - rightPerc),

                    Headline = headline,
                    Source = source,
                    Image = img,

                    Success = true,
                }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new ServiceResponse
                {
                    Success = false,
                    Error = "An error has occured. Please try again later."
                }));
            }
        }
Beispiel #11
0
 public AllDifferentConstraintBuilder WithName(string theName)
 {
     this.name = new ModelName(theName);
     return(this);
 }
 public ExpressionConstraintBuilder WithName(string theName)
 {
     this.name = new ModelName(theName);
     return(this);
 }
Beispiel #13
0
        private async Task <BPFCEstablishDto> AddBPFC(BPFCEstablishDtoForImportExcel bPFCEstablishDto)
        {
            var result = new BPFCEstablishDto();

            // make model name, model no, article no, process
            using (var scope = new TransactionScope(TransactionScopeOption.Required,
                                                    new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }, TransactionScopeAsyncFlowOption.Enabled))
            {
                // make model name
                var modelName = await _repoModelName.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(bPFCEstablishDto.ModelName.ToUpper()));

                if (modelName != null)
                {
                    result.ModelNameID = modelName.ID;
                }
                else
                {
                    var modelNameModel = new ModelName {
                        Name = bPFCEstablishDto.ModelName
                    };
                    _repoModelName.Add(modelNameModel);
                    await _repoModelNo.SaveAll();

                    result.ModelNameID = modelNameModel.ID;
                }
                // end make model no

                // Make model no
                var modelNo = await _repoModelNo.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(bPFCEstablishDto.ModelNo.ToUpper()) && x.ModelNameID == result.ModelNameID);

                if (modelNo != null)
                {
                    result.ModelNoID = modelNo.ID;
                }
                else
                {
                    var modelNoModel = new ModelNo {
                        Name = bPFCEstablishDto.ModelNo, ModelNameID = result.ModelNameID
                    };
                    _repoModelNo.Add(modelNoModel);
                    await _repoModelNo.SaveAll();

                    result.ModelNoID = modelNoModel.ID;
                }
                // end make model NO

                // end make articleNO

                var artNo = await _repoArticleNo.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(bPFCEstablishDto.ArticleNo.ToUpper()) && x.ModelNoID == result.ModelNoID);

                if (artNo != null)
                {
                    result.ArticleNoID = artNo.ID;
                }
                else
                {
                    // make art no
                    var articleNoModel = new ArticleNo {
                        Name = bPFCEstablishDto.ArticleNo, ModelNoID = result.ModelNoID
                    };
                    _repoArticleNo.Add(articleNoModel);
                    await _repoArticleNo.SaveAll();

                    result.ArticleNoID = articleNoModel.ID;
                }
                // end articleNO
                //  make Art Process

                var artProcess = await _repoArtProcess.FindAll().FirstOrDefaultAsync(x => x.ProcessID.Equals(bPFCEstablishDto.Process.ToUpper() == "STF" ? 2 : 1) && x.ArticleNoID == result.ArticleNoID);

                if (artProcess != null)
                {
                    result.ArtProcessID = artProcess.ID;
                }
                else
                {
                    // make art process
                    var artProcessModel = new ArtProcess {
                        ArticleNoID = result.ArticleNoID, ProcessID = bPFCEstablishDto.Process.ToUpper() == "STF" ? 2 : 1
                    };
                    _repoArtProcess.Add(artProcessModel);
                    await _repoArtProcess.SaveAll();

                    result.ArtProcessID = artProcessModel.ID;
                }
                //End  make Art Process

                result.CreatedBy = bPFCEstablishDto.CreatedBy;
                scope.Complete();
                return(result);
            }
        }
Beispiel #14
0
 protected Wrecker(ModelName modelName) : base(ModelName.Wrecker, 10, 2)
 {
 }
Beispiel #15
0
 public override string Log() => $"{Category.PadRight(15)}{ProdName.PadRight(8)}{ModelName.PadRight(8)}{PurchaseDate.ToShortDateString().PadRight(8)}{Price}";
Beispiel #16
0
 protected FiveTon(ModelName modelName) : base(ModelName.FiveTon, 10, 2)
 {
 }
Beispiel #17
0
        private void CreateStructuralInterfaceEquivalent(CyPhy.Component cyphycomp)
        {
            CyPhy.CADModel cadmodel = cyphycomp.Children.CADModelCollection.FirstOrDefault(x => x.Attributes.FileFormat == CADFormat);
            if (cadmodel != null)
            {
                string uri;
                cadmodel.TryGetResourcePath(out uri);
                char[] start = new char[] { '/', '\\' };
                if (!String.IsNullOrEmpty(uri) && CADFormat == CyPhyClasses.CADModel.AttributesClass.FileFormat_enum.Creo)
                {
                    uri = uri.TrimStart(start);

                    string absPath;
                    cadmodel.TryGetResourcePath(out absPath, ComponentLibraryManager.PathConvention.ABSOLUTE);
                    var hyperlink = cyphycomp.ToHyperLink(Traceability);
                    missingFile = Task.Run(() => CheckFileExists(hyperlink, uri, absPath));

                    // META-1382
                    //ModelName = UtilityHelpers.CleanString2(Path.GetFileNameWithoutExtension(uri));
                    ModelName = Path.GetFileName(uri);
                    List <string> tokens_2 = ModelName.Split('.').ToList <string>();
                    int           index    = tokens_2.FindIndex(x => x.ToUpper() == "PRT");
                    if (index != -1)
                    {
                        ModelType = "Part";
                        ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                    }
                    else
                    {
                        index = tokens_2.FindIndex(x => x.ToUpper() == "ASM");
                        if (index != -1)
                        {
                            ModelType = "Assembly";
                            ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                        }
                    }
                    // It shouldn't be an empty string
                    if (ModelType.Length == 0)
                    {
                        ModelType = "Part";
                    }
                }
                else
                {
                    Logger.Instance.AddLogMessage("CADModel Resource Path information unavailable for component [" + cyphycomp.Path + "," + DisplayID + "]!", Severity.Warning);
                }

                ModelURI = uri.Length > 0 ? Path.GetDirectoryName(uri) : "";
                //ModelType = cadmodel.Attributes.FileType.ToString();

                foreach (var param in cadmodel.Children.CADParameterCollection)
                {
                    CADParameter acadparam = new CADParameter(param);
                    CadParameters.Add(acadparam);
                }

                // META-947: Connector replaced StructuralInterface
                //           Not dealing with nested Connectors right now.
                // foreach (var item in cyphycomp.Children.StructuralInterfaceCollection)
                foreach (CyPhy.Connector item in cyphycomp.Children.ConnectorCollection)
                {
                    FindMatchingSolidModelingFeatures(item, cadmodel);
                }

                foreach (CyPhy.CADDatum item in cyphycomp.Children.CADDatumCollection)
                {
                    // only Coordinate System is supported
                    if (item is CyPhy.CoordinateSystem)
                    {
                        FindMatchingSolidModelingFeatures(item, cadmodel);
                    }
                    //else
                    //    Logger.Instance.AddLogMessage("Only CoordinateSystem datums outside of a Connector are supported, other datum types not supported.", Severity.Warning);
                }

                // Materials
                if (cyphycomp.Children.MaterialRefCollection.Any())
                {
                    CyPhy.MaterialRef matRef   = cyphycomp.Children.MaterialRefCollection.First();
                    CyPhy.Material    material = matRef.Referred.Material;
                    if (material != null)
                    {
                        this.MaterialName = material.Attributes.Name;
                    }
                }
            }
        }
Beispiel #18
0
        public void DoGen()
        {
            File.WriteAllText($"{ControllerDir}\\{ModelName}Controller.cs", GenerateController(), Encoding.UTF8);

            File.WriteAllText($"{VmDir}\\{ModelName}VM.cs", GenerateVM("CrudVM"), Encoding.UTF8);
            File.WriteAllText($"{VmDir}\\{ModelName}ListVM.cs", GenerateVM("ListVM"), Encoding.UTF8);
            File.WriteAllText($"{VmDir}\\{ModelName}BatchVM.cs", GenerateVM("BatchVM"), Encoding.UTF8);
            File.WriteAllText($"{VmDir}\\{ModelName}ImportVM.cs", GenerateVM("ImportVM"), Encoding.UTF8);
            File.WriteAllText($"{VmDir}\\{ModelName}Searcher.cs", GenerateVM("Searcher"), Encoding.UTF8);

            if (UI == UIEnum.LayUI)
            {
                File.WriteAllText($"{ViewDir}\\Index.cshtml", GenerateView("ListView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\Create.cshtml", GenerateView("CreateView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\Edit.cshtml", GenerateView("EditView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\Delete.cshtml", GenerateView("DeleteView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\Details.cshtml", GenerateView("DetailsView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\Import.cshtml", GenerateView("ImportView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\BatchEdit.cshtml", GenerateView("BatchEditView"), Encoding.UTF8);
                File.WriteAllText($"{ViewDir}\\BatchDelete.cshtml", GenerateView("BatchDeleteView"), Encoding.UTF8);
            }
            if (UI == UIEnum.React)
            {
                if (Directory.Exists($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}") == false)
                {
                    Directory.CreateDirectory($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}");
                }
                if (Directory.Exists($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views") == false)
                {
                    Directory.CreateDirectory($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views");
                }
                if (Directory.Exists($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\store") == false)
                {
                    Directory.CreateDirectory($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\store");
                }
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\action.tsx", GenerateReactView("action"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\details.tsx", GenerateReactView("details"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\models.tsx", GenerateReactView("models"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\other.tsx", GenerateReactView("other"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\search.tsx", GenerateReactView("search"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\views\\table.tsx", GenerateReactView("table"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\store\\index.ts", GetResource("index.txt", "Spa.React.store").Replace("$modelname$", ModelName.ToLower()), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\index.tsx", GetResource("index.txt", "Spa.React").Replace("$modelname$", ModelName.ToLower()), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\{ModelName.ToLower()}\\style.less", GetResource("style.txt", "Spa.React").Replace("$modelname$", ModelName.ToLower()), Encoding.UTF8);

                var index = File.ReadAllText($"{MainDir}\\ClientApp\\src\\pages\\index.ts");
                if (index.Contains($"path: '/{ModelName.ToLower()}'") == false)
                {
                    index = index.Replace("/**WTM**/", $@"
, {ModelName.ToLower()}: {{
        name: '{ModuleName.ToLower()}',
        path: '/{ModelName.ToLower()}',
        component: () => import('./{ModelName.ToLower()}').then(x => x.default) 
    }}
/**WTM**/
 ");
                    File.WriteAllText($"{MainDir}\\ClientApp\\src\\pages\\index.ts", index, Encoding.UTF8);
                }

                var menu = File.ReadAllText($"{MainDir}\\ClientApp\\src\\subMenu.json");
                if (menu.Contains($@"""Path"": ""/{ModelName.ToLower()}""") == false)
                {
                    var i = menu.LastIndexOf("}");
                    menu = menu.Insert(i + 1, $@"
,{{
        ""Key"": ""{Guid.NewGuid().ToString()}"",
        ""Name"": ""{ModuleName.ToLower()}"",
        ""Icon"": ""menu-fold"",
        ""Path"": ""/{ModelName.ToLower()}"",
        ""Component"": ""{ModelName.ToLower()}"",
        ""Action"": [],
        ""Children"": []
    }}
");
                    File.WriteAllText($"{MainDir}\\ClientApp\\src\\subMenu.json", menu, Encoding.UTF8);
                }
            }
        }
Beispiel #19
0
        public bool LoadFormFile(string filePath)
        {
            if (File.Exists(filePath))
            {
                StreamReader file = new StreamReader(filePath);
                //Read first line to check format
                string line = file.ReadLine();
                if (line.Split(',').Length != 11)
                {
                    return(false);
                }

                while ((line = file.ReadLine()) != null)
                {
                    string[] lines = line.Split(',');
                    if (lines.Length != 11)
                    {
                        Console.WriteLine("ERROR!: {0}", line);
                        continue;
                    }
                    string manufac     = lines[0];
                    string modelname   = lines[1];
                    string devicename  = lines[2];
                    string modelcode   = lines[3];
                    string gpu         = lines[4];
                    string formfactor  = lines[5];
                    string sysonchip   = lines[6];
                    string totalmem    = lines[7];
                    string abis        = lines[8];
                    string glesversion = lines[9];
                    string sdk         = lines[10];

                    DeviceSpec deviceSpec = new DeviceSpec
                    {
                        GPU          = gpu,
                        FormFactor   = formfactor,
                        SystemOnChip = sysonchip,
                        TotalMem     = totalmem,
                        ABIs         = abis,
                        OpenGLESVer  = glesversion,
                        SDKs         = sdk
                    };

                    ModelCode modelCode = new ModelCode
                    {
                        Name = modelcode,
                        Spec = deviceSpec
                    };

                    DeviceName deviceName = new DeviceName
                    {
                        Name       = devicename,
                        ModelCodes = new List <ModelCode> {
                            modelCode
                        }
                    };

                    ModelName modelName = new ModelName
                    {
                        Name        = modelname,
                        DeviceNames = new List <DeviceName> {
                            deviceName
                        }
                    };
                    // find manufac
                    if (Manufacturers.Any(x => x.Name == manufac))
                    {
                        Manufacturer Manufac = Manufacturers.First(x => x.Name == manufac);
                        if (!Manufac.Add(modelName))
                        {
                            Console.WriteLine("Warning!: Duplicate device {0}", line);
                            Console.WriteLine("Warning!: at Manufacturers[{0}]", line, Manufacturers.IndexOf(Manufac));
                        }
                    }
                    else
                    {
                        Manufacturer newManufac = new Manufacturer
                        {
                            Name       = manufac,
                            ModelNames = new List <ModelName> {
                                modelName
                            }
                        };
                        Manufacturers.Add(newManufac);
                    }
                }
            }
            return(false);
        }
        //----------------------------------//
        // 関数名	GetModel				//
        //    Function name GetModel
        // 機能		モデルを取得する			//
        //    I get the functional model
        // 引数		モデルの識別ナンバー		//
        //    Identification number of arguments model
        // 戻り値	モデル					//
        //    Returns model
        //----------------------------------//
        public Model GetModel(ModelName name)
        {
            // I examine whether the range
            if (name < 0 || name >= ModelName.MaxModelNum)
            {
                return null;
            }

            // Return null if none
            if (this.model[(int)name] == null)
            {
                return null;
            }
            return this.model[(int)name];
        }
 /// <summary>
 /// Initialize a new variable renamed message with the previous variable name and the
 /// variable that has been renamed.
 /// </summary>
 /// <param name="thePreviousName">Previous variable name.</param>
 /// <param name="theVariable">The renamed variable.</param>
 public VariableRenamedMessage(ModelName thePreviousName, VariableModel theVariable)
 {
     PreviousName = thePreviousName.Text;
     Renamed      = theVariable;
 }
Beispiel #22
0
        public void PlaceOrder(ModelName modelName, double price, int quantity)
        {
            Model = modelName.ToString();
            if (price < 10000.0)
                throw new ArgumentOutOfRangeException("price");
            Price = price;
            if (quantity > 2)
                throw new ArgumentOutOfRangeException("quantity");
            Quantity = quantity;

            switch (modelName)
            {
                case ModelName.BMW520:
                    OrderedVehicle = new Automobile(250, "Automobile", 4.0, 6.0, 2.5);
                    break;
                case ModelName.BMW320:
                    OrderedVehicle = new Automobile(220, "Automobile", 3.5, 5.0, 2);
                    break;
                case ModelName.BMW235:
                    OrderedVehicle = new Automobile();
                    break;
                case ModelName.HondaCruiser:
                    OrderedVehicle = new Motocycle(70, "Motocycle", 1.5, 1.5);
                    break;
                case ModelName.HondaSport:
                    OrderedVehicle = new Motocycle(60, "Motocycle", 1.2, 1.2);
                    break;
                case ModelName.HondaTouring:
                    OrderedVehicle = new Motocycle();
                    break;
                default:
                    break;
            }
        }
Beispiel #23
0
 public ActionResult Login(ModelName model)
 {
     return(View("VewName"));
 }