public void ShowDetailWindow(int lscId, string projectId) { try { var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return; } var connectionString = WebUtility.CreateLscConnectionString(lsc); var project = new BAppointment().GetProject(lsc.LscID, lsc.LscName, projectId, connectionString); if (project == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取工程信息"); return; } ProjectIdField.Text = project.ProjectId; ProjNameField.Text = project.ProjectName; StartTimeField.Text = WebUtility.GetDateString(project.BeginTime); EndTimeField.Text = WebUtility.GetDateString(project.EndTime); ResponsibleField.Text = project.Responsible; PhoneField.Text = project.ContactPhone; CompanyField.Text = project.Company; CommentField.Text = project.Comment; EnabledField.Text = WebUtility.GetBooleanName(project.Enabled); DetailWindow.Show(); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
protected void UpdateBtn_Click(object sender, EventArgs e) { try { var lsc = new LscInfo(); lsc.LscID = Int32.Parse(LscIDTextBox.Text.Trim()); lsc.LscName = LscNameTextBox.Text.Trim(); lsc.LscIP = LscIPTextBox.Text.Trim(); lsc.LscPort = Int32.Parse(LscPortTextBox.Text.Trim()); lsc.LscUID = LscUIDTextBox.Text.Trim(); lsc.LscPwd = LscPwdTextBox.Text.Trim(); lsc.BeatInterval = Int32.Parse(BeatIntervalTextBox.Text.Trim()); lsc.BeatDelay = Int32.Parse(BeatDelayTextBox.Text.Trim()); lsc.DBServer = DBIPTextBox.Text.Trim(); lsc.DBPort = Int32.Parse(DBPortTextBox.Text.Trim()); lsc.DBName = DBNameTextBox.Text.Trim(); lsc.DBUID = DBUIDTextBox.Text.Trim(); lsc.DBPwd = DBPwdTextBox.Text.Trim(); lsc.HisDBServer = HisDBIPTextBox.Text.Trim(); lsc.HisDBPort = Int32.Parse(HisDBPortTextBox.Text.Trim()); lsc.HisDBName = HisDBNameTextBox.Text.Trim(); lsc.HisDBUID = HisDBUIDTextBox.Text.Trim(); lsc.HisDBPwd = HisDBPwdTextBox.Text.Trim(); lsc.Connected = false; lsc.ChangedTime = DateTime.Now; lsc.Enabled = EnabledCheckBox.Checked; var lscEntity = new BLsc(); lscEntity.UpdateLsc(lsc); var lscs = lscEntity.GetLscs(); gvLsc.DataSource = lscs; gvLsc.DataBind(); } catch (Exception err) { handleError(err.Message); } }
public void DelLsc(int lscId) { try { var lscEntity = new BLsc(); lscEntity.DelLsc(lscId); var order = new OrderInfo(); order.LscID = lscId; order.TargetID = -1; order.TargetType = EnmNodeType.Null; order.OrderType = EnmActType.DeleteLsc; order.RelValue1 = Page.User.Identity.Name; order.RelValue2 = WebUtility.GetClientIP(); order.RelValue3 = WebUtility.DefaultString; order.RelValue4 = WebUtility.DefaultString; order.RelValue5 = WebUtility.DefaultString; order.UpdateTime = DateTime.Now; var orderEntity = new BOrder(); orderEntity.AddOrder(order); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
public string UpdateLsc() { try { var lsc = new LscInfo(); lsc.LscID = (int)LSCIDField.Number; lsc.LscName = LSCNameField.Text.Trim(); lsc.LscIP = LSCIPField.Text.Trim(); lsc.LscPort = (int)LSCPortField.Number; lsc.LscUID = LSCUIDField.Text.Trim(); lsc.LscPwd = LSCPwdField.Text.Trim(); lsc.BeatInterval = (int)BeatIntervalField.Number; lsc.BeatDelay = (int)BeatDelayField.Number; lsc.DBServer = DBIPField.Text.Trim(); lsc.DBPort = (int)DBPortField.Number; lsc.DBName = DBNameField.Text.Trim(); lsc.DBUID = DBUIDField.Text.Trim(); lsc.DBPwd = DBPwdField.Text.Trim(); lsc.HisDBServer = HisDBIPField.Text.Trim(); lsc.HisDBPort = (int)HisDBPortField.Number; lsc.HisDBName = HisDBNameField.Text.Trim(); lsc.HisDBUID = HisDBUIDField.Text.Trim(); lsc.HisDBPwd = HisDBPwdField.Text.Trim(); lsc.Connected = false; lsc.ChangedTime = DateTime.Now; lsc.Enabled = EnabledCheckbox.Checked; var lscEntity = new BLsc(); lscEntity.UpdateLsc(lsc); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 200, "数据保存成功")); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, err.Message)); } }
/// <summary> /// Window Project ComboBox Refresh /// </summary> protected void OnWProjectRefresh(object sender, StoreRefreshDataEventArgs e) { try { var data = new List <object>(); if (WLscsComboBox.SelectedItem.Value != null && WLscsComboBox.SelectedItem.Value != String.Empty) { var lscId = Int32.Parse(WLscsComboBox.SelectedItem.Value); var lsc = new BLsc().GetLsc(lscId); if (lsc != null) { var connectionString = WebUtility.CreateLscConnectionString(lsc); var projects = new BAppointment().GetProjectItem(lsc.LscID, lsc.LscName, connectionString); foreach (var p in projects) { data.Add(new { Id = p.ProjectId, Name = p.ProjectName }); } } } WProjectStore.DataSource = data; WProjectStore.DataBind(); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Event Type ComboBox Refresh /// </summary> protected void OnEventTypeRefresh(object sender, StoreRefreshDataEventArgs e) { try { var data = new List <object>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); var lsc = new BLsc().GetLsc(lscId); if (lsc != null) { var comboboxEntity = new BComboBox(); var dict = comboboxEntity.GetAcMessageType(WebUtility.CreateLscConnectionString(lsc)); if (dict != null && dict.Count > 0) { foreach (var key in dict) { data.Add(new { Id = key.Key, Name = key.Value }); } } } } } if (data.Count == 0) { var lscs = new BLsc().GetLscs().FindAll(l => l.Enabled); foreach (var lsc in lscs) { var comboboxEntity = new BComboBox(); var dict = comboboxEntity.GetAcMessageType(WebUtility.CreateLscConnectionString(lsc)); if (dict != null && dict.Count > 0) { foreach (var key in dict) { data.Add(new { Id = key.Key, Name = key.Value }); } break; } } } EventTypeStore.DataSource = data; EventTypeStore.DataBind(); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Submit Nodes /// </summary> protected void SubmitNodes(object sender, SubmitEventArgs e) { try { var columns = new List <ACVFilterInfo>(); foreach (var sNode in e.RootNode.Children) { var column = new ACVFilterInfo(); column.ColName = sNode.Text; column.FilterItem = sNode.Attributes["filterItem"].ToString(); var filterType = Int32.Parse(sNode.Attributes["filterType"].ToString()); column.FilterType = Enum.IsDefined(typeof(EnmActiveValuesFiteType), filterType) ? (EnmActiveValuesFiteType)filterType : EnmActiveValuesFiteType.NodeName; var nodeType = Int32.Parse(sNode.Attributes["vNodeType"].ToString()); column.NodeType = Enum.IsDefined(typeof(EnmNodeType), nodeType) ? (EnmNodeType)nodeType : EnmNodeType.Null; column.DevName = sNode.Attributes["devName"].ToString(); column.IsNew = Boolean.Parse(sNode.Attributes["isNew"].ToString()); columns.Add(column); } if (columns.Count > 0 && LscsComboBox.SelectedItem != null) { var nodeId = LscsComboBox.SelectedItem.Value; var ids = WebUtility.ItemSplit(nodeId); if (ids.Length != 2) { WebUtility.ShowNotify(EnmErrType.Warning, "获取客户端参数时发生错误,数据保存失败!"); return; } var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); var lscEntity = new BLsc(); var lsc = lscEntity.GetLsc(lscId); if (lsc == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取客户端信息,数据保存失败!"); return; } var userData = UserData; var lscUser = userData.LscUsers.Find(lui => { return(lui.LscID == lsc.LscID); }); if (lscUser == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取用户信息,数据保存失败!"); return; } var connectionString = WebUtility.CreateLscConnectionString(lsc); var reportSettingEntity = new BSetting(); columns = reportSettingEntity.UpdateLSCActiveValuesFilterCols(connectionString, lscUser.UID, columns); reportSettingEntity.UpdateCSCActiveValuesFilterCols(lscUser.LscID, lscUser.UID, columns); lscUser.ActiveValuesFiterItem = columns; WebUtility.ShowNotify(EnmErrType.Info, "数据已保存成功!"); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Refresh LSC List /// </summary> protected void OnLSCListRefresh(object sender, StoreRefreshDataEventArgs e) { try { var start = Int32.Parse(e.Parameters["start"]); var limit = Int32.Parse(e.Parameters["limit"]); var end = start + limit; var data = new List <object>(limit); var lscEntity = new BLsc(); var lscs = lscEntity.GetLscs(); if (lscs != null && lscs.Count > 0) { if (end > lscs.Count) { end = lscs.Count; } for (int i = start; i < end; i++) { data.Add(new { LscID = lscs[i].LscID, LscName = lscs[i].LscName, LscIP = lscs[i].LscIP, LscPort = lscs[i].LscPort, LscUID = lscs[i].LscUID, LscPwd = lscs[i].LscPwd, BeatInterval = lscs[i].BeatInterval, BeatDelay = lscs[i].BeatDelay, DBServer = lscs[i].DBServer, DBPort = lscs[i].DBPort, DBName = lscs[i].DBName, DBUID = lscs[i].DBUID, DBPwd = lscs[i].DBPwd, HisDBServer = lscs[i].HisDBServer, HisDBPort = lscs[i].HisDBPort, HisDBName = lscs[i].HisDBName, HisDBUID = lscs[i].HisDBUID, HisDBPwd = lscs[i].HisDBPwd, Connected = lscs[i].Connected, ChangedTime = WebUtility.GetDateString(lscs[i].ChangedTime), Enabled = lscs[i].Enabled }); } } e.Total = lscs.Count; LSCStore.DataSource = data; LSCStore.DataBind(); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// UDGSettingWestPanelSubmitNodes /// </summary> protected void UDGSettingWestPanelSubmitNodes(object sender, SubmitEventArgs e) { try { var lscId = LscID; var udGroupID = UDGroupID; var lscEntity = new BLsc(); var lsc = lscEntity.GetLsc(lscId); if (lsc == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取客户端信息,数据保存失败!"); return; } var userData = UserData; var lscUser = userData.LscUsers.Find(lu => { return(lu.LscID == lsc.LscID); }); if (lscUser == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取用户信息,数据保存失败!"); return; } var cacheKey = WebUtility.GetCacheKeyName(userData, "udg-setting-devs"); var devNodes = HttpRuntime.Cache[cacheKey] as List <GroupTreeInfo>; if (devNodes == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取关联设备,数据保存失败!"); return; } var group = new UDGroupInfo(); group.LscID = lscId; group.UserID = lscUser.UserID; group.UDGroupID = udGroupID; group.UDGroupName = UDGroupName.Text; group.UDGroupNodes = new List <UDGroupTreeInfo>(); group.Enabled = true; AddUDGSettingWestPanelSubmitNodes(devNodes, group, e.RootNode); var groupEntity = new BGroup(); string connectionString = WebUtility.CreateLscConnectionString(lsc); group = groupEntity.SaveLSCUDGroupTreeNodes(connectionString, group); groupEntity.SaveCSCUDGroupTreeNodes(group); lscUser.UDGroups.RemoveAll(udg => { return(udg.UDGroupID == group.UDGroupID); }); lscUser.UDGroups.Add(group); UDGroupID = group.UDGroupID; WebUtility.ShowNotify(EnmErrType.Info, "数据已保存成功!"); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Add Data To Cache /// </summary> private List <ProjectInfo> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "projects"); HttpRuntime.Cache.Remove(cacheKey); if (LscsComboBox.SelectedItem.Value == null || LscsComboBox.SelectedItem.Value == String.Empty) { return(null); } var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length != 2) { return(null); } var lscId = Int32.Parse(ids[0]); var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { return(null); } var beginTime = DateTime.Parse(BeginDate.Text); var endTime = DateTime.Parse(EndDate.Text); var projects = new List <ProjectInfo>(); var searchText = QueryContentTextField.Text.Trim(); var connectionString = WebUtility.CreateLscConnectionString(lsc); switch (Int32.Parse(QueryTypeComboBox.SelectedItem.Value)) { case 0: projects.AddRange(new BAppointment().GetProjects(lsc.LscID, lsc.LscName, searchText, null, beginTime, endTime, connectionString)); break; case 1: projects.AddRange(new BAppointment().GetProjects(lsc.LscID, lsc.LscName, null, searchText, beginTime, endTime, connectionString)); break; default: break; } var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, projects, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(projects); }
public string Save() { try { if (WLscsComboBox.SelectedItem.Value != null && WLscsComboBox.SelectedItem.Value.Trim() != String.Empty) { var lscId = Int32.Parse(WLscsComboBox.SelectedItem.Value); var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, "无法获取Lsc信息")); } var project = new ProjectInfo(); project.LscID = lsc.LscID; project.LscName = lsc.LscName; project.ProjectId = ProjectIdField.Text.Trim(); project.ProjectName = ProjNameField.Text.Trim(); project.BeginTime = DateTime.Parse(StartTimeField.Text); project.EndTime = DateTime.Parse(EndTimeField.Text); project.Responsible = ResponsibleField.Text.Trim(); project.ContactPhone = PhoneField.Text.Trim(); project.Company = CompanyField.Text.Trim(); project.Comment = CommentField.Text.Trim(); project.Enabled = EnabledCheckbox.Checked; var apptEntity = new BAppointment(); var connectionString = WebUtility.CreateLscConnectionString(lsc); if (OperationWindowHF.Text.Equals("Add") && apptEntity.ProjectExists(project.ProjectId, connectionString)) { return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, "工程已存在")); } apptEntity.SaveProjects(new List <ProjectInfo>() { project }, connectionString); var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "projects"); HttpRuntime.Cache.Remove(cacheKey); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 200, "数据保存成功")); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, WebUtility.JsonCharFilter(err.Message))); } return(String.Empty); }
/// <summary> /// Submit Nodes /// </summary> protected void SubmitNodes(object sender, SubmitEventArgs e) { try { var lscEntity = new BLsc(); var lscs = lscEntity.GetLscs(); var reportSettingEntity = new BSetting(); var userData = UserData; foreach (var sNode in e.RootNode.Children) { var lsc = lscs.Find(l => { return(l.LscID.ToString().Equals(sNode.NodeID)); }); if (lsc == null) { continue; } var lscUser = userData.LscUsers.Find(lu => { return(lu.LscID == lsc.LscID); }); if (lscUser == null) { continue; } var sp = new SpeechInfo(); sp.SpDisconnect = Boolean.Parse(sNode.Attributes["SpDisconnect"].ToString()); sp.AL1Enabled = Boolean.Parse(sNode.Attributes["AL1Enabled"].ToString()); sp.AL2Enabled = Boolean.Parse(sNode.Attributes["AL2Enabled"].ToString()); sp.AL3Enabled = Boolean.Parse(sNode.Attributes["AL3Enabled"].ToString()); sp.AL4Enabled = Boolean.Parse(sNode.Attributes["AL4Enabled"].ToString()); sp.SpDevFilter = sNode.Attributes["SpDevFilter"].ToString(); sp.SpNodeFilter = sNode.Attributes["SpNodeFilter"].ToString(); sp.SpLoop = Boolean.Parse(sNode.Attributes["SpLoop"].ToString()); sp.SpArea2 = Boolean.Parse(sNode.Attributes["SpArea2"].ToString()); sp.SpArea3 = Boolean.Parse(sNode.Attributes["SpArea3"].ToString()); sp.SpStation = Boolean.Parse(sNode.Attributes["SpStation"].ToString()); sp.SpDevice = Boolean.Parse(sNode.Attributes["SpDevice"].ToString()); sp.SpNode = Boolean.Parse(sNode.Attributes["SpNode"].ToString()); sp.SpALDesc = Boolean.Parse(sNode.Attributes["SpALDesc"].ToString()); sp.UpdateTime = DateTime.Now; var connectionString = WebUtility.CreateLscConnectionString(lsc); var localSpeech = reportSettingEntity.UpdateLSCSpeechFilter(connectionString, sNode.Attributes["SpUID"].ToString(), sp); reportSettingEntity.UpdateCSCSpeechFilter(lsc.LscID, sNode.Attributes["SpUID"].ToString(), sp); lscUser.AlarmSoundFiterItem = sp; } WebUtility.ShowNotify(EnmErrType.Info, "数据已保存成功!"); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
public string GetLscStates() { var userData = UserData; var lscEntity = new BLsc(); var newStates = new List <LscInfo>(); foreach (var lscUser in userData.LscUsers) { var lsc = lscEntity.GetLsc(lscUser.LscID); if (lsc == null) { continue; } if (lsc.Connected) { continue; } newStates.Add(lsc); } if (newStates.Count == 0) { Session.Remove("LscStates"); return(string.Empty); } var oldStates = new List <LscInfo>(); if (Session["LscStates"] != null) { oldStates = Newtonsoft.Json.JsonConvert.DeserializeObject <List <LscInfo> >(Session["LscStates"].ToString()); } var messages = new List <string>(); var show = false; foreach (var dc in newStates.OrderByDescending(d => d.ChangedTime)) { if (!oldStates.Any(o => o.LscID == dc.LscID && o.ChangedTime == dc.ChangedTime)) { show = true; } messages.Add(string.Format("{0}<br/>[{1}] 服务器通信中断", WebUtility.GetDateString(dc.ChangedTime), dc.LscName)); } Session["LscStates"] = Newtonsoft.Json.JsonConvert.SerializeObject(newStates); return(show ? Newtonsoft.Json.JsonConvert.SerializeObject(messages) : string.Empty); }
protected void gvLsc_DataBind() { try { var connectionString = this.ConnectionString; if (String.IsNullOrEmpty(connectionString)) { connectionString = InstallerHelper.ConnectionString; } var lscs = new List <LscInfo>(); if (!String.IsNullOrEmpty(connectionString)) { var lscEntity = new BLsc(); lscs = lscEntity.GetLscs(connectionString); } gvLsc.DataSource = lscs; gvLsc.DataBind(); } catch (Exception err) { handleError(err.Message); } }
public void Delete(int lscId, string projectId) { try { var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return; } ; var connectionString = WebUtility.CreateLscConnectionString(lsc); new BAppointment().DeleteProjects(projectId, connectionString); var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "projects"); HttpRuntime.Cache.Remove(cacheKey); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
public void UpdateMarker(int olscId, int ostaId, int lscId, int staId, int mapType, double lng, double lat, string address) { try { var lscEntity = new BLsc(); var lsc = lscEntity.GetLsc(lscId); if (lsc == null) { WebUtility.ShowNotify(EnmErrType.Warning, "无法获取客户端信息,数据更新失败!"); return; } var otherEntity = new BOther(); var enmMapType = Enum.IsDefined(typeof(EnmMapType), mapType) ? (EnmMapType)mapType : EnmMapType.GPS; var connectionString = WebUtility.CreateLscConnectionString(lsc); otherEntity.UpdateMarker(olscId, ostaId, lscId, staId, enmMapType, lng, lat, address); otherEntity.UpdateLocalMarker(connectionString, ostaId, staId, enmMapType, lng, lat, address); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Add Data To Cache /// </summary> private List <AppointmentInfo> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "appointments"); HttpRuntime.Cache.Remove(cacheKey); if (LscsComboBox.SelectedItem.Value == null || LscsComboBox.SelectedItem.Value == String.Empty) { return(null); } var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length != 2) { return(null); } var lscId = Int32.Parse(ids[0]); var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return(null); } var beginTime = DateTime.Parse(BeginDate.Text); var endTime = DateTime.Parse(EndDate.Text); var queryType = Int32.Parse(QueryTypeComboBox.SelectedItem.Value); var queryText = QueryContentTextField.Text.Trim(); var appointmentEntity = new BAppointment(); var connectionString = WebUtility.CreateLscConnectionString(lsc); var appointments = appointmentEntity.GetAppointments(lsc.LscID, lsc.LscName, connectionString, beginTime, endTime, queryType, queryText); var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, appointments, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(appointments); }
/// <summary> /// Add data to cache. /// </summary> private List <Report110Entity> AddDataToCache() { var userData = UserData; var cacheKey1 = WebUtility.GetCacheKeyName(userData, "kpi-report-110"); var cacheKey2 = WebUtility.GetCacheKeyName(userData, "kpi-report-110-02"); HttpRuntime.Cache.Remove(cacheKey1); HttpRuntime.Cache.Remove(cacheKey2); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var staTypes = new Dictionary <Int32, String>(); foreach (var dt in StaTypeMultiCombo.SelectedItems) { staTypes[Int32.Parse(dt.Value)] = dt.Text; } if (staTypes.Count == 0) { return(null); } var fromTime = DateTime.Parse(BeginDate.Text); var toTime = DateTime.Parse(EndDate.Text); var texts = new List <String>(); var auxSets = new List <String>(); var filterText = WebUtility.StringSplit(NodeText.Text.Trim()); foreach (var ft in filterText) { if (String.IsNullOrEmpty(ft.Trim())) { continue; } if (FilterTypeList.SelectedItem.Value.Equals("1")) { auxSets.Add(ft.Trim()); } else { texts.Add(ft.Trim()); } } var lscEntity = new BLsc(); var nodeEntity = new BNode(); var source1 = new List <Report110Entity>(); var source2 = new Dictionary <String, List <StationInfo> >(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } //var instance = new Dictionary<string, NodeInfo>(); //var nodes = nodeEntity.GetNodes(lsc.LscID, EnmNodeType.Aic, texts.ToArray(), auxSets.ToArray(), null); //foreach (var node in nodes) { // instance[String.Format("{0}-{1}", node.LscID, node.StaID)] = node; //} var stations = new BOther().GetStations(lsc.LscID).FindAll(s => staTypes.ContainsKey(s.StaTypeID)); var values = nodeEntity.GetMaxHisAIV(lsc.LscID, fromTime, toTime); //var temp = from n in instance.Values // join s in stations on new { n.LscID, n.StaID } equals new { s.LscID,s.StaID} // join v in values on new { n.LscID, n.NodeID } equals new { v.LscID, v.NodeID } // select new { // Station = s, // Node = n, // Value = v.Value // }; var temp = from s in stations join v in values on new { s.LscID, s.StaID } equals new { v.LscID, StaID = v.NodeID } select new { Station = s, Value = v.Value }; var correct = temp.Where(n => n.Value >= 1); source2[String.Format("{0}-CorrectCount", source1.Count)] = correct.Any() ? correct.Select(n => n.Station).ToList() : new List <StationInfo>(); source2[String.Format("{0}-AllCount", source1.Count)] = temp.Any() ? temp.Select(n => n.Station).ToList() : new List <StationInfo>(); source1.Add(new Report110Entity { LscID = lsc.LscID, LscName = lsc.LscName, CorrectCount = correct.Count(), AllCount = temp.Count() }); } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey1, source1, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); HttpRuntime.Cache.Insert(cacheKey2, source2, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(source1); }
public string Save() { try { if (WLscsComboBox.SelectedItem.Value != null && WLscsComboBox.SelectedItem.Value != String.Empty) { var lscId = Int32.Parse(WLscsComboBox.SelectedItem.Value); var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, "无法获取客户端信息,数据保存失败。")); } var lscUser = UserData.LscUsers.Find(lui => { return(lui.LscID == lsc.LscID); }); if (lscUser == null) { return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, "无法获取用户信息,数据保存失败。")); } var appointment = new AppointmentInfo(); appointment.LscID = lsc.LscID; appointment.LscName = lsc.LscName; appointment.Id = 0; appointment.StartTime = Convert.ToDateTime(StartTimeTextField.Text); appointment.EndTime = Convert.ToDateTime(EndTimeTextField.Text); appointment.LscIncluded = LscCheckbox.Checked ? lsc.LscID : 0; appointment.StaIncluded = StaIncludedField.Text.Trim(); appointment.DevIncluded = DevIncludedField.Text.Trim(); appointment.ProjectId = WProjectComboBox.SelectedItem.Value; appointment.ProjectName = WProjectComboBox.SelectedItem.Text; appointment.Status = ProjStatusBox.Checked ? EnmProjStatus.End : EnmProjStatus.Start; appointment.CreaterId = lscUser.UserID; appointment.Creater = lscUser.UserName; appointment.ContactPhone = BookingUserPhoneTextField.Text.Trim(); appointment.CreatedTime = DateTime.Now; var value = JsonValueHF.Text; if (!String.IsNullOrEmpty(value)) { var temp = JsonConvert.DeserializeObject <AppointmentInfo>(value); if (temp == null) { return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, "格式转换错误,数据保存失败。")); } appointment.Id = temp.Id; } var connectionString = WebUtility.CreateLscConnectionString(lsc); new BAppointment().SaveAppointment(new List <AppointmentInfo>() { appointment }, connectionString); var cacheKey = WebUtility.GetCacheKeyName(UserData, "appointments"); HttpRuntime.Cache.Remove(cacheKey); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 200, "数据保存成功")); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); return(String.Format("{{\"Status\":{0}, \"Msg\":\"{1}\"}}", 0, err.Message)); } return(String.Empty); }
public void ShowCmdWindow(string cmd, int lscId, string projId) { try { WLscsComboBox.Disabled = false; ProjectIdField.Disabled = false; ProjectIdField.Clear(); ProjNameField.Clear(); StartTimeField.Clear(); EndTimeField.Clear(); ResponsibleField.Clear(); PhoneField.Clear(); CompanyField.Clear(); CommentField.Clear(); EnabledCheckbox.Checked = true; TipsStatusBar.ClearStatus(); switch (cmd) { case "Add": ProjectWindow.Title = "新增工程"; ProjectWindow.Icon = Icon.TagBlueAdd; WLscsComboBox.GetStore().DataBind(); ProjectIdField.Text = Guid.NewGuid().ToString("D").ToUpper(); StartTimeField.Text = WebUtility.GetDateString(DateTime.Today); EndTimeField.Text = WebUtility.GetDateString(DateTime.Today.AddMonths(1).AddSeconds(-1)); OperationWindowHF.Text = "Add"; ProjectWindow.Show(); break; case "Edit": ProjectWindow.Title = "编辑工程"; ProjectWindow.Icon = Icon.TagBlueEdit; WLscsComboBox.Disabled = true; ProjectIdField.Disabled = true; OperationWindowHF.Text = "Edit"; var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return; } var connectionString = WebUtility.CreateLscConnectionString(lsc); var project = new BAppointment().GetProject(lsc.LscID, lsc.LscName, projId, connectionString); if (project == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取工程信息"); return; } WLscsComboBox.SetValueAndFireSelect(lsc.LscID); ProjectIdField.Text = project.ProjectId; ProjNameField.Text = project.ProjectName; StartTimeField.Text = WebUtility.GetDateString(project.BeginTime); EndTimeField.Text = WebUtility.GetDateString(project.EndTime); ResponsibleField.Text = project.Responsible; PhoneField.Text = project.ContactPhone; CompanyField.Text = project.Company; CommentField.Text = project.Comment; EnabledCheckbox.Checked = project.Enabled; ProjectWindow.Show(); break; case "Del": X.Msg.Confirm("确认对话框", "您确定要删除吗?", new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { Handler = String.Format(@" X.ProjectManager.Delete({0},'{1}',{{ success: function(result) {{ MainGridPagingToolbar.doRefresh(); }}, eventMask: {{ showMask: true, target: 'customtarget', msg: '正在删除中...', customTarget: MainGridPanel.body.up('div') }}}});", lscId, projId), Text = "确定" }, No = new MessageBoxButtonConfig { Text = "取消" } }).Show(); break; default: break; } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Add Events To Cache /// </summary> /// <returns>Operating Events</returns> private List <AcEventInfo> AddEventsToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "netking-events"); HttpRuntime.Cache.Remove(cacheKey); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var types = new Dictionary <Int32, String>(); foreach (var dt in EventTypeMultiCombo.SelectedItems) { types[Int32.Parse(dt.Value)] = dt.Text; } var ctype = Convert.ToInt32(CountTypeComboBox.SelectedItem.Value); var fromTime = DateTime.Parse(FromDate.Text); var toTime = DateTime.Parse(ToDate.Text); var lscEntity = new BLsc(); var otherEntity = new BOther(); var result = new List <AcEventInfo>(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } List <AcEventInfo> temp = null; switch (ctype) { case 0: temp = otherEntity.GetPubAlertEvent(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc), fromTime, toTime); break; case 1: temp = otherEntity.GetPubGeneralEvent(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc), fromTime, toTime); break; case 2: temp = otherEntity.GetPubInvalidCardEvent(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc), fromTime, toTime); break; case 3: temp = otherEntity.GetPubValidCardEvent(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc), fromTime, toTime); break; default: break; } if (temp != null) { if (types.Count > 0) { temp = temp.FindAll(t => types.ContainsKey(t.MessageID)); } result.AddRange(temp); } } var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }
protected void gvLsc_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (String.IsNullOrEmpty(e.CommandArgument.ToString())) { return; } var lscId = Int32.Parse(e.CommandArgument.ToString()); var lscEntity = new BLsc(); switch (e.CommandName) { case "Select": LscIDTextBox.Text = String.Empty; LscNameTextBox.Text = String.Empty; LscIPTextBox.Text = String.Empty; LscPortTextBox.Text = String.Empty; LscUIDTextBox.Text = String.Empty; LscPwdTextBox.Attributes["value"] = String.Empty; BeatIntervalTextBox.Text = String.Empty; BeatDelayTextBox.Text = String.Empty; DBIPTextBox.Text = String.Empty; DBPortTextBox.Text = String.Empty; DBNameTextBox.Text = String.Empty; DBUIDTextBox.Text = String.Empty; DBPwdTextBox.Attributes["value"] = String.Empty; HisDBIPTextBox.Text = String.Empty; HisDBPortTextBox.Text = String.Empty; HisDBNameTextBox.Text = String.Empty; HisDBUIDTextBox.Text = String.Empty; HisDBPwdTextBox.Attributes["value"] = String.Empty; EnabledCheckBox.Checked = false; LscIDTextBox.Enabled = false; TitleLabel.Text = "编辑记录"; UpdateBtn.Visible = true; SaveBtn.Visible = false; var lsc = lscEntity.GetLsc(lscId); if (lsc != null) { LscIDTextBox.Text = lsc.LscID.ToString(); LscNameTextBox.Text = lsc.LscName; LscIPTextBox.Text = lsc.LscIP; LscPortTextBox.Text = lsc.LscPort.ToString(); LscUIDTextBox.Text = lsc.LscUID; LscPwdTextBox.Attributes["value"] = lsc.LscPwd; BeatIntervalTextBox.Text = lsc.BeatInterval.ToString(); BeatDelayTextBox.Text = lsc.BeatDelay.ToString(); DBIPTextBox.Text = lsc.DBServer; DBPortTextBox.Text = lsc.DBPort.ToString(); DBNameTextBox.Text = lsc.DBName; DBUIDTextBox.Text = lsc.DBUID; DBPwdTextBox.Attributes["value"] = lsc.DBPwd; HisDBIPTextBox.Text = lsc.HisDBServer; HisDBPortTextBox.Text = lsc.HisDBPort.ToString(); HisDBNameTextBox.Text = lsc.HisDBName; HisDBUIDTextBox.Text = lsc.HisDBUID; HisDBPwdTextBox.Attributes["value"] = lsc.HisDBPwd; EnabledCheckBox.Checked = lsc.Enabled; } ModalPopupExtender.Show(); break; case "Del": lscEntity.DelLsc(lscId); var lscs = lscEntity.GetLscs(); gvLsc.DataSource = lscs; gvLsc.SelectedIndex = -1; gvLsc.DataBind(); break; default: break; } } catch (Exception err) { handleError(err.Message); } }
/// <summary> /// Add data to cache. /// </summary> private List <Report010Entity> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "kpi-report-010"); HttpRuntime.Cache.Remove(cacheKey); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var fromTime = DateTime.Parse(BeginFromDate.Text); var toTime = DateTime.Parse(BeginToDate.Text); var devTypes = new Dictionary <Int32, String>(); foreach (var dt in DevTypeMultiCombo.SelectedItems) { devTypes[Int32.Parse(dt.Value)] = dt.Text; } if (devTypes.Count == 0) { return(null); } var lscEntity = new BLsc(); var otherEntity = new BOther(); var result = new List <Report010Entity>(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } var bats = otherEntity.GetBatStaticCount(lsc.LscID, fromTime, toTime, null, null, 1d / 24d, Int32.MaxValue); var devices = otherEntity.GetDevices(lsc.LscID).FindAll(d => devTypes.ContainsKey(d.AlmDevTypeID)); var batDev = from dev in devices join bat in bats on new { dev.DevID } equals new { DevID = bat.Value } select dev; var parm = Report010Entity.GetLscParam(lsc.LscID, WebUtility.CreateLscConnectionString(lsc)); result.Add(new Report010Entity { LscID = lsc.LscID, LscName = lsc.LscName, ThisCount = batDev == null ? 0 : (fRadio.Checked ? batDev.GroupBy(d => d.StaID).Count() : batDev.GroupBy(d => d.Area3ID).Count()), LastCount = parm != null ? parm.StaTNumber : 0 }); } if (result.Count > 0) { result.Add(new Report010Entity { LscID = -100, LscName = "汇总(平均值)", ThisCount = (Int32)result.Average(r => r.ThisCount), LastCount = (Int32)result.Average(r => r.LastCount) }); } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }
/// <summary> /// Add data to cache. /// </summary> private List <Report014Entity> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "kpi-report-014"); HttpRuntime.Cache.Remove(cacheKey); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var lscEntity = new BLsc(); var result = new List <Report014Entity>(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } var parm = Report014Entity.GetLscParam(lsc.LscID, WebUtility.CreateLscConnectionString(lsc)); var record = new Report014Entity { LscID = lsc.LscID, LscName = lsc.LscName, ThisCount = parm != null ? parm.StaMNumber : 0, LastCount = parm != null ? parm.StaTNumber : 0, }; result.Add(record); } if (result.Count > 0) { result.Add(new Report014Entity { LscID = -100, LscName = "汇总(平均值)", ThisCount = (Int32)result.Average(r => r.ThisCount), LastCount = (Int32)result.Average(r => r.LastCount) }); } var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }
/// <summary> /// Add data to cache. /// </summary> private List <Report007Entity> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "kpi-report-007"); HttpRuntime.Cache.Remove(cacheKey); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var devTypes = new Dictionary <Int32, String>(); foreach (var dt in DevTypeMultiCombo.SelectedItems) { devTypes[Int32.Parse(dt.Value)] = dt.Text; } if (devTypes.Count == 0) { return(null); } var lscEntity = new BLsc(); var otherEntity = new BOther(); var result = new List <Report007Entity>(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } var devices = otherEntity.GetDevices(lsc.LscID).FindAll(d => devTypes.ContainsKey(d.AlmDevTypeID)); var parm = Report007Entity.GetLscParam(lsc.LscID, WebUtility.CreateLscConnectionString(lsc)); result.Add(new Report007Entity { LscID = lsc.LscID, LscName = lsc.LscName, ThisCount = devices.Count, LastCount = parm != null && parm.ElecDevTNumber != WebUtility.DefaultInt32 ? parm.ElecDevTNumber : 0 }); } if (result.Count > 0) { result.Add(new Report007Entity { LscID = -100, LscName = "汇总(平均值)", ThisCount = (Int32)result.Average(r => r.ThisCount), LastCount = (Int32)result.Average(r => r.LastCount) }); } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }
/// <summary> /// Add Data To Cache /// </summary> private List <ProjectReportPageEntity> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "project-report-entities"); HttpRuntime.Cache.Remove(cacheKey); if (LscsComboBox.SelectedItem.Value == null || LscsComboBox.SelectedItem.Value == String.Empty) { return(null); } var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length != 2) { return(null); } var lsc = new BLsc().GetLsc(Int32.Parse(ids[0])); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return(null); } var beginTime = DateTime.Parse(BeginDate.Text); var endTime = DateTime.Parse(EndDate.Text); var area2Id = WebUtility.DefaultInt32; var area3Id = WebUtility.DefaultInt32; if (Area2ComboBox.SelectedIndex > 0) { area2Id = Int32.Parse(Area2ComboBox.SelectedItem.Value); } if (Area3ComboBox.SelectedIndex > 0) { area3Id = Int32.Parse(Area3ComboBox.SelectedItem.Value); } var appointmentEntity = new BAppointment(); var connectionString = WebUtility.CreateLscConnectionString(lsc); var appointments1 = appointmentEntity.GetAppointments(lsc.LscID, lsc.LscName, connectionString, beginTime, endTime, 0, null); var appointments2 = appointmentEntity.GetHisAppointments(lsc.LscID, lsc.LscName, beginTime, endTime, 0, null); appointments1.AddRange(appointments2); var lscappointments = appointments1.FindAll(a => a.LscIncluded == lsc.LscID); var nonappointments = appointments1.FindAll(a => a.LscIncluded != lsc.LscID); var staSet = new List <IDValuePair <int, AppointmentInfo> >(); foreach (var apt in nonappointments) { if (apt.StaIncluded != null && apt.StaIncluded.Trim() != String.Empty) { var array = apt.StaIncluded.Split(';'); foreach (var id in array) { if (id.Trim() != String.Empty) { staSet.Add(new IDValuePair <int, AppointmentInfo>(Int32.Parse(id), apt)); } } } } var devSet = new List <IDValuePair <int, AppointmentInfo> >(); foreach (var apt in nonappointments) { if (apt.DevIncluded != null && apt.DevIncluded.Trim() != String.Empty) { var array = apt.DevIncluded.Split(';'); foreach (var id in array) { if (id.Trim() != String.Empty) { devSet.Add(new IDValuePair <int, AppointmentInfo>(Int32.Parse(id), apt)); } } } } var otherEntity = new BOther(); var stations = otherEntity.GetStations(lsc.LscID); var master1 = from ss in staSet join sta in stations on ss.ID equals sta.StaID select new IDValuePair <int, AppointmentInfo> { ID = sta.Area3ID, Value = ss.Value }; var devices = otherEntity.GetDevices(lsc.LscID); var master2 = from ds in devSet join dev in devices on ds.ID equals dev.DevID select new IDValuePair <int, AppointmentInfo> { ID = dev.Area3ID, Value = ds.Value }; var master = new Dictionary <String, IDValuePair <int, AppointmentInfo> >(); foreach (var mt in master1) { master[String.Format("{0}-{1}", mt.ID, mt.Value.Id)] = mt; } foreach (var mt in master2) { master[String.Format("{0}-{1}", mt.ID, mt.Value.Id)] = mt; } var areas = otherEntity.GetAreas(lsc.LscID); if (area2Id != WebUtility.DefaultInt32) { areas = areas.FindAll(a => a.Area2ID == area2Id); } if (area3Id != WebUtility.DefaultInt32) { areas = areas.FindAll(a => a.Area3ID == area3Id); } foreach (var area in areas) { foreach (var apt in lscappointments) { master[String.Format("{0}-{1}", area.Area3ID, apt.Id)] = new IDValuePair <int, AppointmentInfo>(area.Area3ID, apt); } } var a1 = from mt in master.Values group mt by new { AreaId = mt.ID, mt.Value.ProjectId } into g select new { g.Key.AreaId, g.Key.ProjectId, Time = g.Sum(a => a.Value.EndTime.Subtract(a.Value.StartTime).TotalSeconds) }; var projects = appointmentEntity.GetProjectItem(lsc.LscID, lsc.LscName, connectionString); var a2 = from a in a1 join p in projects on a.ProjectId equals p.ProjectId select new { AreaId = a.AreaId, Time = a.Time, Project = p, IsExProject = a.Time > p.EndTime.Subtract(p.BeginTime).TotalSeconds }; var a3 = from a in a2 group a by new { a.AreaId } into g select new { g.Key.AreaId, Time = g.Sum(p => p.Time), Projects = g.Select(p => p.Project).ToList(), ExProjects = g.Where(p => p.IsExProject).Select(p => p.Project).ToList() }; var a4 = from area in areas join a in a3 on area.Area3ID equals a.AreaId into l from aa in l.DefaultIfEmpty() select new ProjectReportPageEntity { Area = area, Time = aa != null ? aa.Time : 0, Projects = aa != null ? aa.Projects : new List <ProjectInfo>(), ExProjects = aa != null ? aa.ExProjects : new List <ProjectInfo>() }; var result = a4.ToList(); var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }
/// <summary> /// Add data to cache. /// </summary> private List <Report117Entity> AddDataToCache() { var userData = UserData; var cacheKey1 = WebUtility.GetCacheKeyName(userData, "kpi-report-117"); var cacheKey2 = WebUtility.GetCacheKeyName(userData, "kpi-report-117-02"); HttpRuntime.Cache.Remove(cacheKey1); HttpRuntime.Cache.Remove(cacheKey2); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var fromTime = DateTime.Parse(BeginFromDate.Text); var toTime = DateTime.Parse(BeginToDate.Text); var staTypes = new Dictionary <Int32, String>(); foreach (var dt in StaTypeMultiCombo.SelectedItems) { staTypes[Int32.Parse(dt.Value)] = dt.Text; } if (staTypes.Count == 0) { return(null); } var devTypes = new Dictionary <Int32, String>(); foreach (var dt in DevTypeMultiCombo.SelectedItems) { devTypes[Int32.Parse(dt.Value)] = dt.Text; } if (devTypes.Count == 0) { return(null); } var otherEntity = new BOther(); var lscEntity = new BLsc(); var source1 = new List <Report117Entity>(); var source2 = new Dictionary <String, List <StationInfo> >(); foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } var stations = new Dictionary <Int32, String>(); var bats = otherEntity.GetBatStaticCount(lsc.LscID, fromTime, toTime, null, null, 1d / 24d, Int32.MaxValue); if (bats != null && bats.Count > 0) { var devices = otherEntity.GetDevices(lsc.LscID).FindAll(d => staTypes.ContainsKey(d.StaTypeID) && devTypes.ContainsKey(d.DevTypeID)); var temp = from dev in devices join bat in bats on new { dev.LscID, dev.DevID } equals new { LscID = bat.ID, DevID = bat.Value } select dev; foreach (var t in temp) { stations[t.StaID] = t.StaName; } } var stations1 = otherEntity.GetStations(lsc.LscID).FindAll(s => stations.ContainsKey(s.StaID)); var stations2 = Report117Entity.GetStations(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc)); var record = new Report117Entity { LscID = lsc.LscID, LscName = lsc.LscName, ThisCount = stations1.Count, LastCount = stations2.Count }; source1.Add(record); source2[String.Format("{0}-ThisCount", lsc.LscID)] = stations1; source2[String.Format("{0}-LastCount", lsc.LscID)] = stations2; } if (source1.Count > 0) { source1.Add(new Report117Entity { LscID = -100, LscName = "汇总", ThisCount = (Int32)source1.Sum(r => r.ThisCount), LastCount = (Int32)source1.Sum(r => r.LastCount) }); } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey1, source1, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); HttpRuntime.Cache.Insert(cacheKey2, source2, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(source1); }
public void ShowCmdWindow(string cmd, int lscId, int id) { try { StaIncludedField.Clear(); DevIncludedField.Clear(); StartTimeTextField.Clear(); EndTimeTextField.Clear(); BookingUserNameTextField.Clear(); BookingUserPhoneTextField.Clear(); LscCheckbox.Checked = false; ProjStatusBox.Checked = false; WLscsComboBox.Disabled = false; WProjectComboBox.Disabled = false; StaIncludedField.Disabled = false; DevIncludedField.Disabled = false; StartTimeTextField.Disabled = false; EndTimeTextField.Disabled = false; BookingUserPhoneTextField.Disabled = false; LscCheckbox.Disabled = false; ProjStatusBox.Disabled = false; JsonValueHF.Clear(); AppointmentStatusBar.ClearStatus(); var bt = DateTime.Now.AddMinutes(30); var et = bt.AddDays(1); StartTimeTextField.Text = WebUtility.GetDateString(bt); EndTimeTextField.Text = WebUtility.GetDateString(et); switch (cmd) { case "Add": AppointmentWindow.Title = "新增预约"; AppointmentWindow.Icon = Icon.TagBlueAdd; ProjStatusBox.Hide(); WLscsComboBox.GetStore().DataBind(); AppointmentWindow.Show(); break; case "Edit": AppointmentWindow.Title = "编辑预约"; AppointmentWindow.Icon = Icon.TagBlueEdit; ProjStatusBox.Show(); var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return; } var connectionString = WebUtility.CreateLscConnectionString(lsc); var appt = new BAppointment().GetAppointment(lsc.LscID, lsc.LscName, id, connectionString); if (appt == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取预约信息"); return; } if (!UserData.LscUsers.Any(lu => lu.LscID == appt.LscID && lu.UserID == appt.CreaterId)) { WebUtility.ShowMessage(EnmErrType.Warning, "无编辑权限,仅预约设置人有此权限。"); return; } WLscsComboBox.Disabled = true; WProjectComboBox.Disabled = true; if (appt.Status == EnmProjStatus.Using) { StaIncludedField.Disabled = true; DevIncludedField.Disabled = true; StartTimeTextField.Disabled = true; EndTimeTextField.Disabled = true; BookingUserPhoneTextField.Disabled = true; LscCheckbox.Disabled = true; } JsonValueHF.Text = JsonConvert.SerializeObject(appt); WLscsComboBox.SetValueAndFireSelect(appt.LscID); AppointmentWindow.Show(); break; default: break; } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Add data to cache. /// </summary> private List <Report113Entity> AddDataToCache() { var userData = UserData; var cacheKey1 = WebUtility.GetCacheKeyName(userData, "kpi-report-113"); var cacheKey2 = WebUtility.GetCacheKeyName(userData, "kpi-report-113-02"); HttpRuntime.Cache.Remove(cacheKey1); HttpRuntime.Cache.Remove(cacheKey2); var lscIds = new List <int>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length == 2) { var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); lscIds.Add(lscId); } } else { lscIds.AddRange(userData.LscUsers.Select(l => l.LscID)); } if (lscIds.Count == 0) { return(null); } var staTypes = new Dictionary <Int32, String>(); foreach (var dt in StaTypeMultiCombo.SelectedItems) { staTypes[Int32.Parse(dt.Value)] = dt.Text; } if (staTypes.Count == 0) { return(null); } var devTypes = new Dictionary <Int32, String>(); foreach (var dt in DevTypeMultiCombo.SelectedItems) { devTypes[Int32.Parse(dt.Value)] = dt.Text; } if (devTypes.Count == 0) { return(null); } var otherEntity = new BOther(); var lscEntity = new BLsc(); var source1 = new List <Report113Entity>(); var source2 = new Dictionary <String, List <DeviceInfo> >(); var virtualData = WebConfigurationManager.AppSettings["Kpi-HeNan-Virtual-Enable"] != null && WebConfigurationManager.AppSettings["Kpi-HeNan-Virtual-Enable"].Equals("1"); var lscParms = new List <LscParamInfo>(); if (virtualData) { lscParms.AddRange(otherEntity.GetLscParam()); } foreach (var id in lscIds) { var lsc = lscEntity.GetLsc(id); if (lsc == null) { continue; } var devices1 = otherEntity.GetDevices(lsc.LscID).FindAll(d => staTypes.ContainsKey(d.StaTypeID) && devTypes.ContainsKey(d.DevTypeID)); var devices2 = Report113Entity.GetDevices(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc)); var record = new Report113Entity { LscID = lsc.LscID, LscName = lsc.LscName, ThisCount = devices1.Count, LastCount = devices2.Count }; if (virtualData) { var parm = lscParms.Find(l => l.LscID == lsc.LscID); if (parm != null && parm.ElecDevTNumber != WebUtility.DefaultInt32) { record.ThisCount = parm.ElecDevTNumber; } } source1.Add(record); source2[String.Format("{0}-ThisCount", lsc.LscID)] = devices1; source2[String.Format("{0}-LastCount", lsc.LscID)] = devices2; } if (source1.Count > 0) { source1.Add(new Report113Entity { LscID = -100, LscName = "汇总", ThisCount = (Int32)source1.Sum(r => r.ThisCount), LastCount = (Int32)source1.Sum(r => r.LastCount) }); } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey1, source1, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); HttpRuntime.Cache.Insert(cacheKey2, source2, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(source1); }
/// <summary> /// Add data to cache. /// </summary> private List <Report111Entity> AddDataToCache() { var userData = UserData; var cacheKey = WebUtility.GetCacheKeyName(userData, "kpi-report-111"); HttpRuntime.Cache.Remove(cacheKey); var lscs = new List <LscUserInfo>(); if (LscsComboBox.SelectedIndex > 0) { var ids = WebUtility.ItemSplit(LscsComboBox.SelectedItem.Value); if (ids.Length != 2) { return(null); } var lscId = Int32.Parse(ids[0]); var groupId = Int32.Parse(ids[1]); var lscUser = userData.LscUsers.Find(lu => { return(lu.LscID == lscId); }); if (lscUser == null) { return(null); } lscs.Add(lscUser); } else { lscs.AddRange(userData.LscUsers); } var fromTime = DateTime.Parse(BeginFromDate.Text); var toTime = DateTime.Parse(BeginToDate.Text); var texts = new List <String>(); var auxSets = new List <String>(); var filterText = WebUtility.StringSplit(NodeText.Text.Trim()); foreach (var ft in filterText) { if (String.IsNullOrEmpty(ft.Trim())) { continue; } if (FilterTypeList.SelectedItem.Value.Equals("1")) { auxSets.Add(ft.Trim()); } else { texts.Add(ft.Trim()); } } var staTypes = new Dictionary <Int32, String>(); foreach (var dt in StaTypeMultiCombo.SelectedItems) { staTypes[Int32.Parse(dt.Value)] = dt.Text; } if (staTypes.Count == 0) { return(null); } var devTypes = new Dictionary <Int32, String>(); foreach (var dt in DevTypeMultiCombo.SelectedItems) { devTypes[Int32.Parse(dt.Value)] = dt.Text; } if (devTypes.Count == 0) { return(null); } var almNames = new List <String>(); var almIds = new Dictionary <String, String>(); var almText = WebUtility.StringSplit(AlarmNameText.Text.Trim()); foreach (var at in almText) { if (String.IsNullOrEmpty(at.Trim())) { continue; } if (AlmNameList.SelectedItem.Value.Equals("1")) { almIds[at.Trim()] = null; } else { almNames.Add(at.Trim()); } } var nodeEntity = new BNode(); var lscEntity = new BLsc(); var alarmEntity = new BAlarm(); var result = new List <Report111Entity>(); var virtualData = WebConfigurationManager.AppSettings["Kpi-HeNan-Virtual-Enable"] != null && WebConfigurationManager.AppSettings["Kpi-HeNan-Virtual-Enable"].Equals("1"); var lscParms = new List <LscParamInfo>(); if (virtualData) { lscParms.AddRange(new BOther().GetLscParam()); } foreach (var l in lscs) { var lsc = lscEntity.GetLsc(l.LscID); if (lsc == null) { continue; } var stations = Report111Entity.GetStations(lsc.LscID, lsc.LscName, WebUtility.CreateLscConnectionString(lsc)); var nodes = nodeEntity.GetNodes(lsc.LscID, EnmNodeType.Dic, texts.ToArray(), auxSets.ToArray(), devTypes.Keys.ToArray()); if (nodes.Count == 0) { result.Add(new Report111Entity { LscID = lsc.LscID, LscName = lsc.LscName, BeginTime = fromTime, EndTime = toTime, Alarms = new List <AlarmInfo>(), NodeCnt = stations.Count }); } else { var alarms = WebUtility.GetUserAlarms(userData).FindAll(alarm => alarm.LscID == lsc.LscID && alarm.StartTime >= fromTime && alarm.StartTime <= toTime); alarms.AddRange(alarmEntity.GetHisAlarms(lsc.LscID, lsc.LscName, userData.StandardProtocol, l.Group.GroupNodes, fromTime, toTime)); var ta = alarms.FindAll(alarm => { return((almNames.Count == 0 || almNames.Any(name => alarm.AlarmName.Contains(name))) && (almIds.Count == 0 || almIds.ContainsKey(alarm.AlarmID.ToString()))); }); var temp = from alarm in ta join node in nodes on new { alarm.LscID, alarm.NodeID, alarm.NodeType } equals new { node.LscID, node.NodeID, node.NodeType } select alarm; var record = new Report111Entity { LscID = lsc.LscID, LscName = lsc.LscName, BeginTime = fromTime, EndTime = toTime, Alarms = temp.ToList(), NodeCnt = stations.Count }; if (virtualData) { var parm = lscParms.Find(s => s.LscID == lsc.LscID); if (parm != null && parm.StaTNumber != WebUtility.DefaultInt32) { record.NodeCnt = parm.StaTNumber; } } result.Add(record); } } int cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["DefaultCacheDuration"]); HttpRuntime.Cache.Insert(cacheKey, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null); return(result); }