private void InitializeSetup() { msStatus.ServerStatus = STATUS.Stop; labServerStatus.Text = "已停止"; comTimeMinute.SelectedIndex = 2; msSettings.IsCycle = radDeleteYes.Checked; msSettings.Directory = ""; msSettings.Duration = readTime(); options = new string[1]; options[0] = ":rtsp-caching=300"; /**options[1] = ":ttl=12"; * options[2] = ":rtp-caching=300"; */ UISync.Init(this); this.toolDeleteAll.Click += toolDeleteAll_Click; this.toolDeleteSel.Click += toolDeleteSel_Click; mediaTimer = new System.Timers.Timer(); mediaTimer.AutoReset = true; mediaTimer.Elapsed += mediaTimer_Elapsed; mediaTimer.Enabled = false; //初始化操作监听类 osListener = new OperationServer(100, 2000, ""); //osListener.Start(8556); //LinkNumTimer.Start(); //checkDiskEnough() }
public FileSend(byte[] fileByte, string nameF, string extensionFile) { this.fileByte = fileByte; nameFile = nameF; OperationServer.SendMsgClient(512, 1001, this.fileByte.Length, nameF, extensionFile); // OperationServer.SendMsgClient(1032, 1002, new System.IO.MemoryStream(fileByte, 0, 1024, true ,true), 1024); }
public async void UpdateOperationDBAsync(int _id) { if (User == null) { User = db.Users.SingleOrDefault(item => item.Id == _id); GetToken(User); } try { var fromServer = await OperationServer.Get("operations/", User.Token); foreach (Operation newItem in fromServer) { Operation item = db.Operations.Include(op => op.Account). Include(op => op.Category). Include(op => op.Currency). Include(op => op.Purpose). Include(op => op.User). SingleOrDefault(it => it.Id2 == newItem.Id); if (item == null) { newItem.Account = db.Accounts.SingleOrDefault(v => v.Title == newItem.Account.Title); newItem.Category = db.Categories.SingleOrDefault(v => v.Title == newItem.Category.Title); newItem.Currency = db.Currencies.SingleOrDefault(v => v.Title == newItem.Currency.Title); newItem.Purpose = db.Accounts.SingleOrDefault(v => v.Title == newItem.Purpose.Title); newItem.User = User; newItem.Performed = false; await AddItemAsync(newItem); } else { if (item.UpdateTime < newItem.UpdateTime) { if (item.Summ != newItem.Summ) { item.Summ = newItem.Summ; } if (item.Description != newItem.Description) { item.Description = newItem.Description; } await UpdateItemAsync(item); } else { if (item.Summ != newItem.Summ) { newItem.Summ = item.Summ; } if (item.Description != newItem.Description) { newItem.Description = item.Description; } OperationServer.Update(newItem, User.Token); } } } var fromLocal = await GetItemsAsync(User.Id); foreach (Operation newItem in fromLocal) { Operation itemFromServer = fromServer.SingleOrDefault(item => item.Id == newItem.Id2); if (itemFromServer == null) { newItem.Id2 = OperationServer.Add(newItem, User.Token).Id; try { await UpdateItemAsync(newItem); } catch (Exception e) { Console.WriteLine(e); } } else { if (newItem.UpdateTime < itemFromServer.UpdateTime) { if (newItem.Summ != itemFromServer.Summ) { newItem.Summ = itemFromServer.Summ; } if (newItem.Description != itemFromServer.Description) { newItem.Description = itemFromServer.Description; } try { await UpdateItemAsync(newItem); } catch (Exception e) { Console.WriteLine(e); } } else { if (newItem.Summ != itemFromServer.Summ) { itemFromServer.Summ = newItem.Summ; } if (newItem.Description != itemFromServer.Description) { itemFromServer.Description = newItem.Description; } OperationServer.Update(itemFromServer, User.Token); } } } } catch (Exception e) { Console.WriteLine(e); } }
public static void Start() { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { Navigator.AddSettings(new List <EntitySettings> { new EntitySettings <EmployeeEntity>() { View = e => new Employee() }, new EntitySettings <TerritoryEntity>() { View = e => new Territory() }, new EntitySettings <RegionEntity>() { View = e => new Region() }, new EntitySettings <ProductEntity>() { View = e => new Product() }, new EntitySettings <CategoryEntity>() { View = e => new Category(), IsViewable = true }, new EntitySettings <SupplierEntity>() { View = e => new Supplier() }, new EntitySettings <CompanyEntity>() { View = e => new Company() }, new EntitySettings <PersonEntity>() { View = e => new Person() }, new EntitySettings <OrderEntity>() { View = e => new Order() }, }); QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo, b => { b.Converter = SouthwindConverters.ImageConverter; return(Fluent.GetDataTemplate(() => new Image { MaxHeight = 32.0, Stretch = Stretch.Uniform } .Bind(Image.SourceProperty, b) .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear))); }); //Photo QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture, b => { b.Converter = SouthwindConverters.EmbeddedImageConverter; return(Fluent.GetDataTemplate(() => new Image { MaxHeight = 32.0, Stretch = Stretch.Uniform } .Bind(Image.SourceProperty, b) .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear))); }); //Picture Constructor.Register(ctx => new EmployeeEntity { Address = new AddressEmbedded() }); Constructor.Register(ctx => new PersonEntity { Address = new AddressEmbedded() }); Constructor.Register(ctx => new CompanyEntity { Address = new AddressEmbedded() }); Constructor.Register(ctx => new SupplierEntity { Address = new AddressEmbedded() }); OperationClient.AddSettings(new List <OperationSettings>() { new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create) { Constructor = ctx => { var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue return(OperationServer.Construct(OrderOperation.Create, cust)); }, }, new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts) { Click = ctx => { var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue var result = OperationServer.ConstructFromMany(ctx.Entities, OrderOperation.CreateOrderFromProducts, cust); Navigator.Navigate(result); }, }, new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew) { IsVisible = ctx => ctx.Entity.IsNew }, new EntityOperationSettings <OrderEntity>(OrderOperation.Save) { IsVisible = ctx => !ctx.Entity.IsNew }, new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel) { ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null }, new EntityOperationSettings <OrderEntity>(OrderOperation.Ship) { Click = ctx => { DateTime shipDate = DateTime.Now; if (!ValueLineBox.Show(ref shipDate, labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate), owner: Window.GetWindow(ctx.EntityControl))) { return(null); } try { return(ctx.Entity.Execute(OrderOperation.Ship, shipDate)); } catch (IntegrityCheckException e) { ctx.Entity.SetGraphErrors(e); throw e; } }, Contextual = { Click = ctx => { DateTime shipDate = DateTime.Now; if (!ValueLineBox.Show(ref shipDate, labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate), owner: Window.GetWindow(ctx.SearchControl))) { return; } ctx.Entities.SingleEx().ExecuteLite(OrderOperation.Ship, shipDate); } } }, }); //NotDefined } }
static void Main(string[] args) { StringBuilder sbLog = new StringBuilder(); //可变的字符串 DateTime dateTime = DateTime.Now; //获取当前的日期 sbLog.AppendLine(string.Format("数据开始解析,当前时间为:{0}", dateTime.ToString("yyyy-MM-dd HH:mm:ss"))); string beginTime = dateTime.AddDays(-1).ToString("yyyy-MM-dd 09:00:00"); string endTime = dateTime.ToString("yyyy-MM-dd 09:00:00"); OperationServer operationServer = new OperationServer(settingPath); sbLog.AppendLine(string.Format("开始创建文价夹")); string excelPath = Path.Combine(startupPath, @"Result\Excel\"); string logPath = Path.Combine(startupPath, @"Result\Log\"); try { operationServer.CreateDirectory(excelPath); operationServer.CreateDirectory(logPath); sbLog.AppendLine(string.Format("文价夹创建成功")); SendEmailSettingInfo sendEmailSettingInfo = operationServer.GetSendEmailSettingInfo(); DatabaseSetSettingInfo databaseSetSettingInfo = operationServer.GetDatabaseSetSettingInfo(); SqlHelper sqlHelper = new SqlHelper(dbHost: databaseSetSettingInfo.dbHost, dbName: databaseSetSettingInfo.dbName, dbUser: databaseSetSettingInfo.dbUser, dbPwd: databaseSetSettingInfo.dbPwd); DataTable dataTable = operationServer.GetDataTable(sqlHelper, beginTime, endTime, true); sbLog.AppendLine(string.Format("数据获取成功,共有{0}条", dataTable.Rows.Count)); string excelFilePath = string.Empty; if (dataTable != null && dataTable.Rows.Count > 0) { excelFilePath = Path.Combine(excelPath, string.Format("NA354_{0}_{1}_{2}_拦截单.xlsx", dateTime.ToString("yyyy"), dateTime.ToString("MM"), dateTime.ToString("dd"))); NPOIHelper npoiHelper = new NPOIHelper(); npoiHelper.ExportDataTableToExcel(dataTable, excelFilePath); sbLog.AppendLine(string.Format("Excel生成成功,路径为{0}", excelFilePath)); } if (!string.IsNullOrEmpty(excelFilePath)) { StringBuilder tableSB = new StringBuilder(); tableSB.AppendLine("<table border='1' cellspacing='0' cellpadding='0' style='text-align:center;'>"); tableSB.AppendLine("<tr style='background-color:#5b9bd5'>" + "<th width='300px'>deposit_number</th>" + "<th width='350px'>wo_number</th>" + "<th width='200px'>type</th>" + "<th width='200px'>status</th>" + "<th width='300px'>ref_num</th>" + "<th width='200px'>in_param</th>" + "<th width='300px'>err_msg</th>" + "<th width='300px'>updated_on</th>" + "</tr>"); if (dataTable.Rows.Count > 0) { foreach (DataRow row in dataTable.Rows) { tableSB.AppendLine(string.Format("<tr><td>{0}</td><td>{1}</td>" + "<td>{2}</td>" + "<td>{3}</td>" + "<td>{4}</td>" + "<td>{5}</td>" + "<td>{6}</td>" + "<td>{7}</td></tr>", row["deposit_number"].ToString(), row["wo_number"].ToString(), row["type"].ToString(), row["status"].ToString(), row["ref_num"].ToString(), row["in_param"].ToString(), row["err_msg"].ToString(), row["updated_on"].ToString())); } } tableSB.AppendLine($"</table"); sbLog.AppendLine(string.Format("Table拼接成功")); bool flagSentEmail = operationServer.SentEmail(new List <string>() { excelFilePath }, sendEmailSettingInfo, sbLog, dateTime, tableSB); sbLog.AppendLine(string.Format("发送邮件{0}", flagSentEmail ? "成功" : "失败")); } } catch (Exception ex) { sbLog.AppendLine(string.Format("发送错误:{0}", ex.Message)); } string logFilePath = Path.Combine(logPath, "Log_" + dateTime.ToString("yyyyMMddHHmmss") + ".TXT"); TxtHelper.Write(logFilePath, sbLog.ToString()); }