本文整理汇总了C#中SourceType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SourceType.ToString方法的具体用法?C# SourceType.ToString怎么用?C# SourceType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceType
的用法示例。
在下文中一共展示了SourceType.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
/// <summary>
/// Logs the specified messageto EventLog.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="source">The source type.</param>
/// <param name="logType">Type of the log.</param>
public void Log(string message, SourceType source, LogType logType = LogType.Information)
{
var logEntry = new LogEntry
{
Message = message,
Source = source.ToString(),
Type = logType
};
Log(logEntry);
}
示例2: SerializeIcalEventsToIcs
// save the intermediate ics file for the source type represented in ical
private BlobStorageResponse SerializeIcalEventsToIcs(iCalendar ical, SourceType type)
{
var serializer = new DDay.iCal.Serialization.iCalendar.iCalendarSerializer();
var ics_text = serializer.SerializeToString(ical);
var ics_bytes = Encoding.UTF8.GetBytes(ics_text);
var containername = this.id;
return bs.PutBlob(containername, containername + "_" + type.ToString() + ".ics", new Hashtable(), ics_bytes, "text/calendar");
}
示例3: SerializeStatsAndIntermediateOutputs
private void SerializeStatsAndIntermediateOutputs(FeedRegistry fr, EventStore es, iCalendar ical, NonIcalStats stats, SourceType type)
{
BlobStorageResponse bsr;
HttpResponse tsr;
if (BlobStorage.ExistsContainer(this.id) == false)
bs.CreateContainer(this.id, is_public: true, headers: new Hashtable());
if (type == SourceType.ical) // NonIcalStats is null in this case, and not used
{
bsr = fr.SerializeIcalStatsToJson();
GenUtils.LogMsg("info", this.id + ": SerializeIcalStatsToJson", bsr.HttpResponse.status.ToString());
tsr = fr.SaveStatsToAzure();
GenUtils.LogMsg("info", this.id + ": FeedRegistry.SaveStatsToAzure", tsr.status.ToString());
}
else
{
bsr = Utils.SerializeObjectToJson(stats, this.id, stats.blobname + ".json");
GenUtils.LogMsg("info", this.id + ": Collector: SerializeObjectToJson: " + stats.blobname + ".json", bsr.HttpResponse.status.ToString());
tsr = this.SaveStatsToAzure(type);
GenUtils.LogMsg("info", this.id + ": Collector: SaveStatsToAzure", tsr.status.ToString());
}
bsr = this.SerializeIcalEventsToIcs(ical, type);
GenUtils.LogMsg("info", this.id + ": SerializeIcalStatsToIcs: " + id + "_" + type.ToString() + ".ics", bsr.HttpResponse.status.ToString());
bsr = es.Serialize();
GenUtils.LogMsg("info", this.id + ": EventStore.Serialize: " + es.objfile, bsr.HttpResponse.status.ToString());
}
示例4: Save
/// <summary>
/// 存储
/// </summary>
/// <param name="files">文件流</param>
/// <param name="createdUid">created userid</param>
/// <param name="defaultNum"></param>
/// <param name="sourceId">来源ID</param>
/// <param name="sourceType">来源类型</param>
/// <returns></returns>
public List<ResourceEntity> Save(HttpFileCollectionBase files, int createdUid, int defaultNum, int sourceId,
SourceType sourceType)
{
if (files == null || files.Count == 0)
{
return new List<ResourceEntity>(0);
}
var list = new List<ResourceEntity>(files.Count);
var count = files.Count;
//检查扩展名
foreach (string upload in files)
{
if (!files[upload].HasFile()) continue;
/*
* 1.获取存储的文件名
* 2.存储文件
* 3.存储到数据库
* 4.返回
//*/
FileInfor fileInfor;
FileMessage fileuploadResult;
var fileExt = files[upload].FileName.Substring(files[upload].FileName.LastIndexOf(".", System.StringComparison.Ordinal) + 1).ToLower();
switch (sourceType)
{
case SourceType.Product:
case SourceType.Promotion:
//Logger.Warn("switch:" + upload + " ext:" + fileExt + ",ct:" + files[upload].ContentType);
if (files[upload].ContentType.IndexOf("audio/x-m4a", StringComparison.OrdinalIgnoreCase) > -1 || fileExt.IndexOf("m4a", System.StringComparison.OrdinalIgnoreCase) > -1 || upload.LastIndexOf("audio", StringComparison.OrdinalIgnoreCase) > -1)
{
//Logger.Warn("RUN");
var entity2 = InnerSave(files[upload], (sourceType.ToString() + "audio").ToLower(), sourceId, sourceType, createdUid,
count, defaultNum);
if (entity2 != null)
list.Add(entity2);
continue;
}
break;
default:
break;
}
var entity = InnerSave(files[upload], sourceType.ToString().ToLower(), sourceId, sourceType, createdUid,
count--, defaultNum);
if (entity != null)
list.Add(entity);
}
if (list.Count > 0)
{
return _resourceRepository.Insert(list);
}
return new List<ResourceEntity>(0);
}
示例5: SaveStage
/// <summary>
/// implement the saveStage
/// </summary>
/// <param name="file"></param>
/// <param name="sourceType"></param>
/// <returns></returns>
public FileInfor SaveStage(FileInfo file, int createUser, SourceType sourceType)
{
if (file == null)
return null;
FileInfor fileInfor;
var fileuploadResult = FileUploadServiceManager.UploadFile(file, sourceType.ToString().ToLower(),
out fileInfor, string.Empty);
if (fileuploadResult == FileMessage.Success)
{
return fileInfor;
}
else
return null;
}
示例6: GetSourceTypeFile
private string GetSourceTypeFile(SourceType sourceType)
{
string fileName = sourceType.ToString() + ".xml";
string folder = GetFolder();
return Path.Combine(folder, fileName);
}
示例7: ReadTorrent
public LoadRespData ReadTorrent(string file, SourceType source)
{
if (source == SourceType.Torrent)
{
if (string.IsNullOrEmpty(file))
{
P2pProxyApp.Log.Write("Не верная ссылка на торрент", TypeMessage.Error);
throw new Exception("Не верная ссылка на торрент");
}
file = new Uri(file).ToString();
}
Random rand = new Random(DateTime.Now.Millisecond);
string req = String.Format("LOADASYNC {2} {0} {1}", source.ToString().ToUpper(), file, rand.Next(100000, 200000));
if (source != SourceType.ContentId)
req = req + " 0 0 0";
req = req.Replace("CONTENTID", "PID");
//SendMessage("LOADASYNC 126500 PID 1ccf192064ee2d95e91a79f91c6097273d582827");
SendMessage(req.Replace("CONTENTID", "PID"));
int cwait = 0;
bool exit = false;
LoadRespData files = null;
try
{
while (!exit)
{
Thread.Sleep(24);
cwait += 24;
if (cwait >= 1000)
break;
lock (_messagePool)
{
if (!_messagePool.Any())
continue;
foreach (var msg in _messagePool)
{
if (msg.Type == MSG_LOADRESP)
{
exit = true;
var data = (msg.InnerData as LoadRespData);
if (data == null)
break;
files = msg.InnerData as LoadRespData;
break;
//resp.files.AddRange(new String[(msg.InnerData as LoadRespData).Files.Count]);
//foreach (var f in (msg.InnerData as LoadRespData).Files)
// resp.files[(int)f[1]] = f[0].ToString();
}
}
_messagePool.Clear();
}
}
}
catch (Exception)
{
}
return files;
}
示例8: Play
public Task<string> Play(string file, SourceType source, int index = 0)
{
if (source == SourceType.Torrent)
{
if (string.IsNullOrEmpty(file))
{
P2pProxyApp.Log.Write("Не верная ссылка на торрент", TypeMessage.Error);
throw new Exception("Не верная ссылка на торрент");
}
file = new Uri(file).ToString();
}
string req = String.Format("START {0} {1} ", source.ToString().ToUpper(), file);
if (source == SourceType.ContentId)
req = req + index;
else
req = req + index + " 0 0 0";
_playdTask = new Task<string>(WaytingPlay);
_playdTask.Start();
SendMessage(req.Replace("CONTENTID", "PID"));
PlayedFile = file;
return _playdTask;
}
示例9: ZonedEventStore
public ZonedEventStore(Calinfo calinfo, SourceType type)
: base(calinfo)
{
// qualifier is "ical" or one of the non-ical types, so for example:
// http://elmcity.blob.core.windows.net/a2cal/a2cal.ical.zoned.obj
// http://elmcity.blob.core.windows.net/a2cal/a2cal.eventful.zoned.obj
this.objfile = this.id + "." + type.ToString() + ".zoned.obj";
this.uri = BlobStorage.MakeAzureBlobUri(this.id, this.objfile, false);
}
示例10: BuildSourceTypeValue
private string BuildSourceTypeValue(SourceType sources)
{
string value = sources.ToString();
return value.Replace(", ", "+");
}