當前位置: 首頁>>代碼示例>>C#>>正文


C# Alert.AddSuccess方法代碼示例

本文整理匯總了C#中Alert.AddSuccess方法的典型用法代碼示例。如果您正苦於以下問題:C# Alert.AddSuccess方法的具體用法?C# Alert.AddSuccess怎麽用?C# Alert.AddSuccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Alert的用法示例。


在下文中一共展示了Alert.AddSuccess方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: btnSubmit_Click

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BrokenRulesDisplay.ResetBrokenRules();
            Alert alert = new Alert(BrokenRulesDisplay);
            bool canSave = true;

            #region Error Checking

            // Check if a stack is selected
            if (lstSwitches.SelectedIndex < 0)
            {
                alert.AddError("Select Stack Error", "Both a device and a VLAN must be selected before saving the record.");
                canSave = false;
            }

            // Check if the selected VoIP VLAN is used as a Native or Tagged on any interfaces
            if (canSave && lstVLANs.SelectedIndex != 0)
            {
                string query = @"SELECT COUNT(*)
                             FROM InterfaceVLANs
                             WHERE VLANID = " + lstVLANs.SelectedValue;
                int matches = int.Parse(Risque.Utility.SqlHelper.GetSingleSqlValue(query, sdsSwitches.ConnectionString));

                if (matches != 0)
                {
                    alert.AddError("In Use Error", "This VLAN is used elsewhere. A VoIP VLAN cannot be used as a tagged or native VLAN.");
                    canSave = false;
                }
            }

            #endregion Error Checking

            if (canSave)
            {
                // Get the Stack's properties.
                DeviceManagementGroup dmg = DeviceManagementGroup.GetByIdentification(int.Parse(lstSwitches.SelectedValue));

                // Assign the VoIP VLAN to the stack.
                dmg.VoIPVLANID = lstVLANs.SelectedIndex != 0 ? (int?) int.Parse(lstVLANs.SelectedValue) : null;

                // Update the VLAN to be a VoIP Vlan
                if (lstVLANs.SelectedIndex != 0)
                {
                    Vlan v = Vlan.GetByIdentification(int.Parse(lstVLANs.SelectedValue));
                    v.IsVoIP = true;
                    v.Save();
                }

                // Save settings & display success mesage.
                dmg.Save();
                alert.AddSuccess("Success", "Successfully associated device " + lstSwitches.SelectedItem + " with VLAN " + lstVLANs.SelectedItem + ".");
            }

            alert.ShowBrokenRules();
        }
開發者ID:drewjst,項目名稱:Risque,代碼行數:55,代碼來源:SwitchVoIPVLAN.cs

示例2: btnUpload_Click


//.........這裏部分代碼省略.........
                }
            }
            // Create StreamReader
            StreamReader sr = new StreamReader(csvFile);
            try
            {
                if (valid)
                {
                    int i = 0;
                    string line;
                    // Keep track of PICS to deduplicate
                    List<string> validPiCs = new List<string>();

                    // ENTER readline loop
                    while ((line = sr.ReadLine()) != null)
                    {
                        // check line
                        if (line.Equals(string.Empty) || i == 0)
                        {
                            i++;
                            continue;
                        }

                        String strpattern = "[0-9a-z,A-Z\t\v\r\n]";
                        if (!Regex.IsMatch(line, strpattern))
                        {
                            valid = false;
                            alert.AddError("Line invalid", "Line " + (i + 1) + " is invalid.");
                            continue;
                        }
                        //--Split the Line into an Array of Strings using Commas
                        string[] values = line.Split(Convert.ToChar(","));

                        //--Validate Line Numbers
                        String strlinepattern = "^[0-9]+$";
                        if (!Regex.IsMatch(values[0], strlinepattern))
                        {
                            valid = false;
                            alert.AddError("Invalid line number", "Line number at line " + i + " is invalid.");
                        }
                        //Run validation to ensure the line items are in the correct format
                        if (!CheckLine_csv(values, alert, validPiCs))
                        {
                            valid = false;
                        }
                        i++;
                    }
                    if (!validPiCs.Any())
                    {
                        valid = false;
                        alert.AddWarning("No Data", "There were no records in the bulk upload file to be processed.");
                    }

                    if (valid)
                    {
                        i = 0;
                        // Passed checkCSVLine Method -- So add to Line Items
                        csvFile.Seek(0, SeekOrigin.Begin); // Start at the beginning
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Equals(string.Empty) || i == 0)
                            {
                                i++;
                                continue;
                            }
                            //--Fix Excel Weirdness and smart single quotes and apostrophe--//
                            line = Regex.Replace(line, "[\u2018\u2019\u201A]", "'");
                            //--Smart double quotes
                            line = Regex.Replace(line, "[\u201C\u201D\u201E]", "\"");
                            //--Ellipsis
                            line = Regex.Replace(line, "[\u2026\uFFFD]", "...");
                            //--Split line into array using comma
                            string[] values = line.Split(Convert.ToChar(","));
                            //--Add to line items!
                            AddLine_csv(values);
                            i++;
                        }
                    } // END of Readline Loop
                }
            }
            catch
            {
                valid = false;
                alert.AddError("Critical error", "The file submitted includes a critical error and cannot be validated.");
            }
            finally
            {
                sr.Close(); //Close the stream reader
            }
            if (valid)
            {
                alert.AddSuccess("Success", "The items from the uploaded file have been added to this ticket successfully.");
            }
            //Bind The GridViews and Datatables
            BindAmdLineItems();
            BindRepairLineItems();
            alert.ShowBrokenRules();
            //Close the intial Stream
            csvFile.Close();
        }
開發者ID:drewjst,項目名稱:Risque,代碼行數:101,代碼來源:CreateTicket.aspx.cs


注:本文中的Alert.AddSuccess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。