当前位置: 首页>>代码示例>>C#>>正文


C# Operation.ToString方法代码示例

本文整理汇总了C#中System.Operation.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Operation.ToString方法的具体用法?C# Operation.ToString怎么用?C# Operation.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Operation的用法示例。


在下文中一共展示了Operation.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: foreach

        void IJob.Execute(IJobContext context, Operation operation)
        {
            //Gets the mail-addresses with googlemail.com or gmail.com
            foreach (MailAddressEntryObject recipient in _recipientsEntry)
            {
                if (recipient.Address.Address.EndsWith("@gmail.com") ||
                    recipient.Address.Address.EndsWith("@googlemail.com"))
                {
                    _recipients.Add(recipient.Address.Address);
                }
            }
            string to = String.Join(",", _recipients.ToArray());

            //TODO Fetching Longitude and Latitude!
            Dictionary<String, String> geoCode =
                Helpers.GetGeocodes(operation.Einsatzort.Location + " " + operation.Einsatzort.Street + " " + operation.Einsatzort.StreetNumber);
            String longitude = "0";
            String latitude = "0";
            if (geoCode != null)
            {
                longitude = geoCode[Resources.LONGITUDE];
                latitude = geoCode[Resources.LATITUDE];
            }
            String body = operation.ToString(SettingsManager.Instance.GetSetting("eAlarm", "text").GetString());
            String header = operation.ToString(SettingsManager.Instance.GetSetting("eAlarm", "header").GetString());
            var postParameters = new Dictionary<string, string>
                                     {
                                         {"email", to},
                                         {"header", header},
                                         {"text", body},
                                         {"long", longitude},
                                         {"lat", latitude}
                                     };
            string postData = postParameters.Keys.Aggregate("",
                                                            (current, key) =>
                                                            current +
                                                            (HttpUtility.UrlEncode(key) + "=" +
                                                             HttpUtility.UrlEncode(postParameters[key]) + "&"));

            byte[] data = Encoding.UTF8.GetBytes(postData);
            webRequest.ContentLength = data.Length;

            Stream requestStream = webRequest.GetRequestStream();
            var webResponse = (HttpWebResponse)webRequest.GetResponse();
            Stream responseStream = webResponse.GetResponseStream();

            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            if (responseStream != null)
            {
                var reader = new StreamReader(responseStream, Encoding.Default);
                string pageContent = reader.ReadToEnd();
                reader.Close();
                responseStream.Close();
                webResponse.Close();

                //TODO Analyzing Response
            }
        }
开发者ID:pineiro,项目名称:AlarmWorkflow,代码行数:60,代码来源:eAlarm.cs

示例2: ExportCustomTextFile

 private void ExportCustomTextFile(Operation operation)
 {
     using (StreamWriter sw = new StreamWriter(_configuration.CustomTextDestinationFileName, false, Encoding.UTF8))
     {
         sw.Write(operation.ToString(_configuration.CustomTextFormat));
     }
 }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:7,代码来源:OperationFileExporterJob.cs

示例3: SendToProwl

        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            string header = _settings.GetSetting(SettingKeysJob.Header).GetValue<string>();

            string expression = _settings.GetSetting(SettingKeysJob.MessageContent).GetValue<string>();
            string message = operation.ToString(expression);

            Task.Factory.StartNew(() => SendToProwl(operation, message, header));
            Task.Factory.StartNew(() => SendToNotifyMyAndroid(operation, message, header));
        }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:15,代码来源:PushJob.cs

示例4: GetRecipients

        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            IList<MobilePhoneEntryObject> recipients = GetRecipients(operation);
            if (recipients.Count == 0)
            {
                Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsErrorMessage);
                return;
            }

            string format = _settings.GetSetting("SMSJob", "MessageFormat").GetValue<string>();
            string text = operation.ToString(format);
            text = text.Replace("Ö", "Oe").Replace("Ä", "Ae").Replace("Ü", "Ue").Replace("ö", "oe").Replace("ä", "ae").Replace("ü", "ue").Replace("ß", "ss");
            // Truncate the string if it is too long
            text = text.Truncate(160, true, true);

            // Invoke the provider-send asynchronous because it is a web request and may take a while
            _provider.Send(_userName, _password, recipients.Select(r => r.PhoneNumber), text);
        }
开发者ID:Bolde,项目名称:AlarmWorkflow,代码行数:23,代码来源:SMSJob.cs

示例5: SendMail

        private void SendMail(Operation operation, IJobContext context)
        {
            using (MailMessage message = new MailMessage())
            {
                IList<MailAddressEntryObject> recipients = GetMailRecipients(operation);
                if (recipients.Count == 0)
                {
                    Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsMessage);
                    return;
                }

                message.From = _senderEmail;
                foreach (MailAddressEntryObject recipient in recipients)
                {
                    switch (recipient.Type)
                    {
                        case MailAddressEntryObject.ReceiptType.CC: message.CC.Add(recipient.Address); break;
                        case MailAddressEntryObject.ReceiptType.Bcc: message.Bcc.Add(recipient.Address); break;
                        default:
                        case MailAddressEntryObject.ReceiptType.To: message.To.Add(recipient.Address); break;
                    }
                }

                try
                {
                    message.Subject = operation.ToString(_mailSubject, ObjectFormatterOptions.RemoveNewlines, null);
                    message.Body = operation.ToString(_mailBodyFormat);

                    message.BodyEncoding = Encoding.UTF8;
                    message.Priority = MailPriority.High;
                    message.IsBodyHtml = false;

                    if (_attachImage)
                    {
                        Attachment attachment = null;
                        if (context.Parameters.Keys.Contains("ImagePath"))
                        {
                            string imagePath = (string)context.Parameters["ImagePath"];
                            if (!string.IsNullOrWhiteSpace(imagePath))
                            {
                                if (File.Exists(imagePath))
                                {
                                    string[] convertTiffToJpeg = Helpers.ConvertTiffToJpeg(imagePath);
                                    Stream stream = Helpers.CombineBitmap(convertTiffToJpeg).ToStream(ImageFormat.Jpeg);
                                    attachment = new Attachment(stream, "fax.jpg");
                                    foreach (string s in convertTiffToJpeg)
                                    {
                                        File.Delete(s);
                                    }
                                }
                            }
                        }
                        if (attachment != null)
                        {
                            message.Attachments.Add(attachment);
                        }
                    }

                    _smptClient.Send(message);
                }
                catch (Exception ex)
                {
                    SmtpException smtpException = ex as SmtpException;
                    if (smtpException != null)
                    {
                        Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SendExceptionSMTPMessage, smtpException.StatusCode, smtpException.Message);
                    }
                    else
                    {
                        Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SendExceptionMessage);
                    }
                    Logger.Instance.LogException(this, ex);
                }
            }
        }
开发者ID:Bolde,项目名称:AlarmWorkflow,代码行数:75,代码来源:MailingJob.cs

示例6: DictObjToTableStore

 // try to insert a dict<str,obj> into table store
 // if conflict, try to merge or update
 public static TableStorageListDictResponse DictObjToTableStore(Operation operation, Dictionary<string, object> dict, string table, string partkey, string rowkey)
 {
     TableStorage ts = MakeDefaultTableStorage();
     var entity = new Dictionary<string, object>();
     entity.Add("PartitionKey", partkey);
     entity.Add("RowKey", rowkey);
     foreach (var key in dict.Keys)
         if (key != "PartitionKey" && key != "RowKey")
             entity.Add(key, dict[key]);
     var response = ts.InsertEntity(table, entity);
     if (response.http_response.status != HttpStatusCode.Created)
     {
         switch (operation)
         {
             case Operation.update:
                 response = ts.UpdateEntity(table, partkey, rowkey, entity);
                 break;
             case Operation.merge:
                 response = ts.MergeEntity(table, partkey, rowkey, entity);
                 break;
             default:
                 GenUtils.LogMsg("info", "DictToTableStore unexpected operation", operation.ToString());
                 break;
         }
         if (response.http_response.status != HttpStatusCode.NoContent)
         {
             GenUtils.PriorityLogMsg("error", "DictToTableStore: " + operation, response.http_response.status.ToString() + ", " + response.http_response.message);
         }
     }
     return response;
 }
开发者ID:jalbertbowden,项目名称:elmcity,代码行数:33,代码来源:TableStorage.cs

示例7: NotifyMyAndroid

 private void NotifyMyAndroid(Operation operation)
 {
     string content = operation.ToString(_expression);
     List<String> nmaRecipients = (from pushEntryObject in GetRecipients(operation) where pushEntryObject.Consumer == "NMA" select pushEntryObject.RecipientApiKey).ToList();
     if (nmaRecipients.Count != 0)
     {
         try
         {
             NMA.Notify(nmaRecipients, ApplicationName, HeaderText, content, NMANotificationPriority.Emergency);
         }
         catch (Exception ex)
         {
             Logger.Instance.LogFormat(LogType.Error, this, Resources.ErrorNMA, ex.Message);
             Logger.Instance.LogException(this, ex);
         }
     }
 }
开发者ID:Bolde,项目名称:AlarmWorkflow,代码行数:17,代码来源:PushJob.cs

示例8: PerformanceTest

        public static void PerformanceTest(Operation operation)
        {
            Console.WriteLine("*****" + operation.ToString().ToUpper() + "*****");

            int resultInt = IntegerValue;
            StopWatch.Start();

            for (int i = 0; i < OperationCount; i++)
            {
                switch (operation)
                {
                    case Operation.Add:
                        resultInt += IntegerValue;
                        break;
                    case Operation.Substract:
                        resultInt -= IntegerValue;
                        break;
                    case Operation.Multiply:
                        resultInt *= IntegerValue;
                        break;
                    case Operation.Divide:
                        resultInt /= IntegerValue;
                        break;
                    default:
                        throw new InvalidOperationException("Invalid operation!");
                }
            }

            StopWatch.Stop();
            Console.WriteLine("{0,-20}:{1}", "Int", StopWatch.Elapsed);
            StopWatch.Reset();

            long resultLong = LongValue;
            StopWatch.Start();

            for (int i = 0; i < OperationCount; i++)
            {
                switch (operation)
                {
                    case Operation.Add:
                        resultLong += LongValue;
                        break;
                    case Operation.Substract:
                        resultLong -= LongValue;
                        break;
                    case Operation.Multiply:
                        resultLong *= LongValue;
                        break;
                    case Operation.Divide:
                        resultLong /= LongValue;
                        break;
                    default:
                        throw new InvalidOperationException("Invalid operation!");
                }
            }

            StopWatch.Stop();
            Console.WriteLine("{0,-20}:{1}", "Long", StopWatch.Elapsed);
            StopWatch.Reset();

            float resultFloat = FloatValue;
            StopWatch.Start();

            for (int i = 0; i < OperationCount; i++)
            {
                switch (operation)
                {
                    case Operation.Add:
                        resultFloat += FloatValue;
                        break;
                    case Operation.Substract:
                        resultFloat -= FloatValue;
                        break;
                    case Operation.Multiply:
                        resultFloat *= FloatValue;
                        break;
                    case Operation.Divide:
                        resultFloat /= FloatValue;
                        break;
                    default:
                        throw new InvalidOperationException("Invalid operation!");
                }
            }

            StopWatch.Stop();
            Console.WriteLine("{0,-20}:{1}", "Float", StopWatch.Elapsed);
            StopWatch.Reset();

            double resultDouble = DoubleValue;
            StopWatch.Start();

            for (int i = 0; i < OperationCount; i++)
            {
                switch (operation)
                {
                    case Operation.Add:
                        resultDouble += DoubleValue;
                        break;
                    case Operation.Substract:
                        resultDouble -= DoubleValue;
//.........这里部分代码省略.........
开发者ID:ivanvasilev,项目名称:Telerik-Academy-Homeworks,代码行数:101,代码来源:MathOperationsTester.cs

示例9: FormatMnemonic

 //protected virtual void FormatPrefix(StringBuilder sb, Prefixes prefix)
 //{
 //    sb.Append((prefix & Prefixes.Group1).ToString());
 //}
 public virtual string FormatMnemonic(Operation operation)
 {
     return operation.ToString().ToLowerInvariant();
 }
开发者ID:meloscheng,项目名称:dos-debugger,代码行数:8,代码来源:InstructionFormatter.cs

示例10: FormatMnemonic

 public override string FormatMnemonic(Operation operation)
 {
     var attribute = operation.GetAttribute<DescriptionAttribute>();
     if (attribute != null)
     {
         string description = attribute.Description;
         return string.Format("<span title=\"{2}: {0}\">{1}</span>",
             attribute.Description.EscapeXml(),
             operation.ToString().ToLowerInvariant(),
             operation);
     }
     return base.FormatMnemonic(operation);
 }
开发者ID:meloscheng,项目名称:dos-debugger,代码行数:13,代码来源:Symbolic.cs

示例11: getURIs

        private static List<URIish> getURIs(RemoteConfig cfg, Operation op)
        {
            switch (op)
            {
                case Operation.FETCH:
                    return cfg.URIs;

                case Operation.PUSH:
                    List<URIish> uris = cfg.PushURIs;
                    if (uris.Count == 0)
                    {
                        uris = cfg.URIs;
                    }
                    return uris;

                default:
                    throw new ArgumentException(op.ToString());
            }
        }
开发者ID:deodelacruz,项目名称:GitSharp,代码行数:19,代码来源:Transport.cs

示例12: GetRecipients

        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            string body = operation.ToString(_settings.GetSetting("eAlarm", "text").GetValue<string>());
            string header = operation.ToString(_settings.GetSetting("eAlarm", "header").GetValue<string>());
            string location = operation.Einsatzort.ToString();

            bool encryption = _settings.GetSetting("eAlarm", "Encryption").GetValue<bool>();
            if (encryption)
            {
                string encryptionKey = _settings.GetSetting("eAlarm", "EncryptionKey").GetValue<string>();

                body = Helper.Encrypt(body, encryptionKey);
                header = Helper.Encrypt(header, encryptionKey);
                location = Helper.Encrypt(location, encryptionKey);
            }

            string[] to = GetRecipients(operation).Where(pushEntryObject => pushEntryObject.Consumer == "eAlarm").Select(pushEntryObject => pushEntryObject.RecipientApiKey).ToArray();

            Content content = new Content()
            {
                registration_ids = to,
                data = new Content.Data()
               {
                   awf_title = header,
                   awf_message = body,
                   awf_location = location
               }
            };

            string message = new JavaScriptSerializer().Serialize(content);

            HttpStatusCode result = 0;
            if (!SendGcmNotification(ApiKey, message, ref result))
            {
                Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result);
            }
        }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:42,代码来源:eAlarm.cs

示例13: drawResultEPBasedGraph

        private void drawResultEPBasedGraph(ref Chart chart, TrapezoidFuzzyNumber fnumA, TrapezoidFuzzyNumber fnumB, Operation operation, Color color)
        {
            // calculate result points list
            decimal xA, xB, xResult;
            decimal aProbability, bProbability, minProbability;
            CPoint tempPoint = null;
            List<CPoint> resultPointList = new List<CPoint>();
            xA = fnumA.BottomLeft;
            while (xA <= fnumA.BottomRight)
            {
                xB = fnumB.BottomLeft;
                while (xB <= fnumB.BottomRight)
                {
                    xResult = ExtensionPrinciple.Calculate(operation, xA, xB);
                    //if (operation == Operation.Mul || operation == Operation.Div)
                    xResult = Math.Round(xResult, numOfFracDigi);

                    aProbability = fnumA.Probability(xA);
                    bProbability = fnumB.Probability(xB);
                    minProbability = Math.Min(aProbability, bProbability);

                    tempPoint = resultPointList.FirstOrDefault(p => p.x == xResult);
                    if (tempPoint == null)
                    {
                        resultPointList.Add(new CPoint(xResult, minProbability));
                    }
                    else
                    {
                        tempPoint.y = Math.Max(tempPoint.y, minProbability);
                    }

                    xB += smooth;
                }

                xA += smooth;
            }

            // chart by line
            Series seriesLine = chart.Series.Add(operation.ToString());
            seriesLine.ChartType = SeriesChartType.Line;
            seriesLine.BorderWidth = 2;
            seriesLine.Color = color;
            // chart by point
            Series seriesPoint = chart.Series.Add(operation.ToString() + "_point");
            seriesPoint.ChartType = SeriesChartType.Point;
            seriesPoint.BorderWidth = 2;
            seriesPoint.Color = color;
            seriesPoint.IsVisibleInLegend = false;

            // draw the graph
            foreach (CPoint p in resultPointList.OrderBy(i => i.x))
            {
                // by line
                if (checkBoxDrawLine.Checked)
                    seriesLine.Points.AddXY(p.x, p.y);
                // by point
                seriesPoint.Points.AddXY(p.x, p.y);
            }

            addLog(operation.ToString() + " num of point :" + resultPointList.Count.ToString());
            resultPointList.Clear();
        }
开发者ID:bs135,项目名称:FuzzyNumberCalc,代码行数:62,代码来源:FormMain.cs

示例14: drawResultIntervalBasedGraph

        private void drawResultIntervalBasedGraph(ref Chart chart, TrapezoidFuzzyNumber fnumA, TrapezoidFuzzyNumber fnumB, Operation operation, Color color)
        {
            // calculate result points list
            decimal y = 0;
            Interval acut, a, b;
            List<CPoint> resultPointListLeft = new List<CPoint>();
            List<CPoint> resultPointListRight = new List<CPoint>();
            while (y <= 1)
            {
                a = fnumA.AlphaCut(y);
                b = fnumB.AlphaCut(y);
                acut = ArithmeticInterval.Calculate(operation, a, b);

                resultPointListLeft.Add(new CPoint(acut.LowerBound, y));
                resultPointListRight.Add(new CPoint(acut.UpperBound, y));
                y += smooth;
            }

            y = 1;
            a = fnumA.AlphaCut(y);
            b = fnumB.AlphaCut(y);
            acut = ArithmeticInterval.Calculate(operation, a, b);
            decimal x = acut.LowerBound;
            while (x <= acut.UpperBound)
            {
                resultPointListLeft.Add(new CPoint(x, y));
                x += smooth;
            }

            // chart by line
            Series seriesLine = chart.Series.Add(operation.ToString());
            seriesLine.ChartType = SeriesChartType.Line;
            seriesLine.BorderWidth = 2;
            seriesLine.Color = color;
            // chart by point
            Series seriesPoint = chart.Series.Add(operation.ToString() + "_point");
            seriesPoint.ChartType = SeriesChartType.Point;
            seriesPoint.BorderWidth = 2;
            seriesPoint.Color = color;
            seriesPoint.IsVisibleInLegend = false;

            // draw the graph
            foreach (CPoint p in resultPointListLeft.OrderBy(i => i.x).OrderBy(i => i.y))
            {
                // by line
                if (checkBoxDrawLine.Checked)
                    seriesLine.Points.AddXY(p.x, p.y);
                // by point
                seriesPoint.Points.AddXY(p.x, p.y);
            }
            foreach (CPoint p in resultPointListRight.OrderBy(i => i.x).OrderByDescending(i => i.y))
            {
                // by line
                if (checkBoxDrawLine.Checked)
                    seriesLine.Points.AddXY(p.x, p.y);
                // by point
                seriesPoint.Points.AddXY(p.x, p.y);
            }

            addLog(operation.ToString() + " num of point :" + (resultPointListLeft.Count + resultPointListRight.Count).ToString());
            resultPointListLeft.Clear();
            resultPointListRight.Clear();
        }
开发者ID:bs135,项目名称:FuzzyNumberCalc,代码行数:63,代码来源:FormMain.cs

示例15: GetRecipients

        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            string body = operation.ToString(_settings.GetSetting("eAlarm", "text").GetValue<string>());
            string header = operation.ToString(_settings.GetSetting("eAlarm", "header").GetValue<string>());
            string location = operation.Einsatzort.ToString();
            bool encryption = _settings.GetSetting("eAlarm", "Encryption").GetValue<bool>();
            string encryptionKey = _settings.GetSetting("eAlarm", "EncryptionKey").GetValue<string>();
            if (encryption)
            {
                body = Helper.Encrypt(body, encryptionKey);
                header = Helper.Encrypt(header, encryptionKey);
                location = Helper.Encrypt(location, encryptionKey);
            }

            string[] to = GetRecipients(operation).Where(pushEntryObject => pushEntryObject.Consumer == "eAlarm").Select(pushEntryObject => pushEntryObject.RecipientApiKey).ToArray();

            Content content = new Content()
            {
                registration_ids = to,
                data = new Content.Data()
                    {
                        awf_title = header,
                        awf_message = body,
                        awf_location = location
                    }
            };
            string message = new JavaScriptSerializer().Serialize(content);

            HttpStatusCode result = 0;
            if (SendGCMNotification("AIzaSyA5hhPTlYxJsEDniEoW8OgfxWyiUBEPiS0", message, ref result))
            {
                Logger.Instance.LogFormat(LogType.Info, this, "Succesfully sent eAlarm notification");
            }
            else
            {
                Logger.Instance.LogFormat(LogType.Error, this, "Error while sending eAlarm notification Errorcode: '{0}'", (int)result);
            }
        }
开发者ID:Bolde,项目名称:AlarmWorkflow,代码行数:43,代码来源:eAlarm.cs


注:本文中的System.Operation.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。