/// <summary> /// 按照工点聚类,单位工程显示第一个 /// </summary> /// <returns></returns> public static List <ConsLocation> clusterConsFromWebByProj(string fromDate = null, string toDate = null) { List <ConsLocation> ls = new List <ConsLocation>(); double cx, cy; //string fromD = DateTime.Now.AddDays(-7).ToShortDateString(); //string toD = DateTime.Now.ToShortDateString(); //dt2.Columns.Add("ProjectName", typeof(string)); //dt2.Columns.Add("DwName", typeof(string)); //dt2.Columns.Add("Longitude", typeof(double)); //dt2.Columns.Add("Latitude", typeof(double)); //dt2.Columns.Add("StaffNum", typeof(int)); // 2016-05-06 00:00:00Z //DataTable dt = CServerWrapper.findClusterConsByPDW(DateTime.Now.AddDays(-7).Date.ToString("u")); //DataTable dt = CServerWrapper.findClusterConsByPDW(fromDate, toDate); DataTable dt = CServerWrapper.findClusterConsByProj(fromDate, toDate); foreach (DataRow dr in dt.Rows) { GPSAdjust.bd_decrypt(Convert.ToDouble(dr["Latitude"]), Convert.ToDouble(dr["Longitude"]), out cy, out cx); ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), cx, cy, fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"]))); // ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), //fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"]))); } return(ls); //new StaticCluster().clusterProcess(); }
public static int refreshMsgLog() { if (CServerWrapper.isConnected) { DataTable dt = CServerWrapper.findMsgLog(DateTime.Now.AddHours(-24)); if (dt == null || dt.Rows.Count == 0) { return(0); } //DatabaseWrapper.PrintDataTable(dt); //if (mLogInfo.Count == 0 || mLogInfo.Count > 0 && dt.Rows[0]["CreateTime"].ToString() != mLogTime[0].ToString()) //{ //refreshd = true; mLogInfo.Clear(); mLogTime.Clear(); mLogX.Clear(); mLogY.Clear(); foreach (DataRow dr in dt.Rows) { mLogInfo.Add(dr["Description"].ToString()); mLogTime.Add(Convert.ToDateTime(dr["CreateTime"])); } //} return(dt.Rows.Count); } return(0); }
/// <summary> /// 如果绑定控件,DataTable方式可以减少数据复制,但本应用需要对数据做聚类处理,需要用上面方法做数据的初步解析 /// </summary> /// <param name="date"></param> /// <returns></returns> private static DataTable findConsFromDate(string date) { //DataTable dt = CServerWrapper.findConsInfo(DateTime.Now.AddDays(-30).Date.ToString("u")); DataTable dt = CServerWrapper.findConsInfo(date); return(dt); }
/// <summary> /// 利用dkcode 与 里程初始化,潜在问题,要求在同一个链中,dkcode一致,目前数据库中的里程描述description不正确 /// </summary> /// <param name="s"></param> /// <param name="SerialNo"></param> /// <param name="projID"></param> /// <param name="profName"></param> /// <param name="ProjectName"></param> /// <param name="SegmentName"></param> /// <param name="DKCode"></param> /// <param name="Mileage_Start"></param> /// <param name="Mileage_Mid"></param> /// <param name="Mileage_End"></param> /// <param name="dt"></param> /// <param name="AvgProgress"></param> /// <param name="dir"></param> /// <param name="labelFile"></param> /// <param name="length"></param> public CRailwayProject(CRailwayScene s, string SerialNo, int projID, string profName, string ProjectName, string SegmentName, string DKCode, double Mileage_Start, double Mileage_Mid, double Mileage_End, //string Mileage_Start_Des, string Mileage_Mid_Des, string Mileage_End_Des, DateTime dt, double AvgProgress, double dir, string labelFile) { mScene = s; ProfessionalName = profName; mProjectID = projID; mProjectName = ProjectName; mSegmentName = SegmentName; mSerialNo = SerialNo; mDKCode = DKCode; Mileage_Start_Ds = CRailwayLineList.CombiDKCode(DKCode, Mileage_Start); //Mileage_Mid_Ds = Mileage_Mid_Des; Mileage_End_Ds = CRailwayLineList.CombiDKCode(DKCode, Mileage_End);; ///Doing //DataSet ds = CServerWrapper.findProjHistory(mSerialNo); //if (ds != null) //{ // PrintDataTable(ds.Tables[0]); // PrintDataTable(ds.Tables[1]); //} //else //{ // Console.WriteLine("None Data " + ProjectName); //} ///FIXME, 描述在数据库中不准确,待修正 double tmp; //mScene.mMiddleLines.parseDKCode(Mileage_Start_Des, out mDKCode_Start, out tmp); //mScene.mMiddleLines.parseDKCode(Mileage_Mid_Des, out mDKCode_Mid, out tmp); //mScene.mMiddleLines.parseDKCode(Mileage_End_Des, out mDKCode_End, out tmp); mMileage_Start = Mileage_Start; mMileage_Mid = Mileage_Mid; mMileage_End = Mileage_End; mIsValid = mScene.mMiddleLines.getPosbAndLengthByDKCode(mDKCode, mMileage_Mid, out mLongitude_Mid, out mLatitude_Mid, out mAltitude_Mid, out mHeading_Mid, out tmp); mIsValid &= mScene.mMiddleLines.getPosbAndLengthByDKCode(mDKCode, mMileage_Start, out mLongitude_Start, out mLatitude_Start, out mAltitude_Start, out mHeading_Start, out mGlobalMileage); mIsValid &= mScene.mMiddleLines.getPosbAndLengthByDKCode(mDKCode, mMileage_End, out mLongitude_End, out mLatitude_End, out mAltitude_End, out mHeading_End, out tmp); mUpdateTime = dt; mDirection = dir; mLabelImage = labelFile; mLength = Math.Abs(mMileage_End - mMileage_Start); //FIXME 目前是导入,不同DKCode的线路如何求解 mds = CServerWrapper.findProjHistory(mSerialNo); getFXProgress(); }
public static DataTable findGeneralInfo(string sql) { int num = 0; //DataTable dt = CServerWrapper.findConsInfo(DateTime.Now.AddDays(-30).Date.ToString("u")); DataTable dt = CServerWrapper.execSqlQuery(sql); num = dt.Rows.Count; if (num == 0) { return(null); } return(dt); }
public static DataTable findPhotosByProjSNo(string sno) { string sql = @"select Top 5 FileName, PhotoTime, ReferenceSerialNo, Person, Remark from PhotoInfo where ReferenceSerialNo = '" + sno + @"' order by PhotoTime desc;"; DataTable dt = null; if (isConnected) { dt = CServerWrapper.execSqlQuery(sql); if (dt != null) { foreach (DataRow dr in dt.Rows) { dr["FileName"] = "/ProjectPhoto/" + dr["ReferenceSerialNo"].ToString().Substring(0, 3) + "/" + Convert.ToDateTime(dr["PhotoTime"].ToString()).Year + "/" + dr["FileName"].ToString().Replace("#", "%23"); // HttpUtility.UrlEncode(dr["FileName"].ToString()); } } } return(dt); }
//<xs:element name="PhotoName" type="xs:string" minOccurs="0"/> //<xs:element name="FileName" type="xs:string" minOccurs="0"/> //<xs:element name="FileSize" type="xs:double" minOccurs="0"/> //<xs:element name="PhotoTime" type="xs:dateTime" minOccurs="0"/> //<xs:element name="Longitude" type="xs:double" minOccurs="0"/> //<xs:element name="Latitude" type="xs:double" minOccurs="0"/> //<xs:element name="ReferenceSerialNo" type="xs:string" minOccurs="0"/> //<xs:element name="Person" type="xs:string" minOccurs="0"/> //<xs:element name="Remark" type="xs:string" minOccurs="0"/> // public static public static int findConsPhoto(int topN, out string[] photoName, out string[] fileName, out string[] photoTime, out double[] longitude, out double[] latitude, out string[] sNo, out string[] person, out string[] remark) { int num = 0; photoName = fileName = photoTime = sNo = person = remark = null; longitude = latitude = null; //DataTable dt = CServerWrapper.findConsInfo(DateTime.Now.AddDays(-30).Date.ToString("u")); DataTable dt = CServerWrapper.findLatestImage(topN); num = dt.Rows.Count; if (num == 0) { return(0); } photoName = new string[num]; fileName = new string[num]; photoTime = new string[num]; sNo = new string[num]; person = new string[num]; remark = new string[num]; longitude = new double[num]; latitude = new double[num]; int i = 0; foreach (DataRow dr in dt.Rows) { photoName[i] = dr["PhotoName"].ToString(); fileName[i] = CGisDataSettings.gCurrentProject.projectUrl + "/" + dr["FileName"].ToString(); // Console.WriteLine(fileName[i]); photoTime[i] = dr["PhotoTime"].ToString(); sNo[i] = dr["ReferenceSerialNo"].ToString(); person[i] = dr["Person"].ToString(); remark[i] = dr["Remark"].ToString(); longitude[i] = Convert.ToDouble(dr["Longitude"]); latitude[i] = Convert.ToDouble(dr["Latitude"]); //FIXME 更新Web 服务 i++; } return(num); }
//public static int findLast30Cons(out string[] usrName, out string[] projName, out string[] consDate, out double[] longitude, out double[] latitude) //{ // return findConsFromDate(DateTime.Now.AddDays(-30).Date.ToString("u"), out usrName, out projName, out consDate, out longitude, out latitude); //} //public static int findLast365Cons(out string[] usrName, out string[] projName, out string[] consDate, out double[] longitude, out double[] latitude) //{ // return findConsFromDate(DateTime.Now.AddDays(-365).Date.ToString("u"), out usrName, out projName, out consDate, out longitude, out latitude); //} private static int findConsFromDate(string date, out string[] usrName, out string[] projName, out string[] projDWName, out double[] longitude, out double[] latitude) { int num = 0; usrName = projName = projDWName = null; longitude = latitude = null; //DataTable dt = CServerWrapper.findConsInfo(DateTime.Now.AddDays(-30).Date.ToString("u")); DataTable dt = CServerWrapper.findConsInfo(date); //DatabaseWrapper.PrintDataTable(dt); num = dt.Rows.Count; if (num == 0) { return(0); } usrName = new string[num]; projName = new string[num]; projDWName = new string[num]; longitude = new double[num]; latitude = new double[num]; int i = 0; foreach (DataRow dr in dt.Rows) { usrName[i] = dr["UsrName"].ToString(); projName[i] = dr["ProjectName"].ToString(); projDWName[i] = dr["DwName"].ToString(); longitude[i] = Convert.ToDouble(dr["Longitude"]); latitude[i] = Convert.ToDouble(dr["Latitude"]); i++; } return(num); }
/// <summary> /// string sqlstr = @"select FirmName ,a.FirmTypeID, CategoryCode, SerialNo, UpdateTime, Longitude, Latitude from (select * from FirmInfo)a, (select FirmTypeID,FirmTypeCategoryName from FirmTypeInfo)b where a.FirmTypeID=b.FirmTypeID and( FirmTypeCategoryName='单位' or FirmTypeCategoryName='分支机构') and Longitude > 10 AND Latitude > 10 order by a.FirmTypeID asc ;"; /// </summary> private void initFirmsFromServer() //string projCode, List<CRailwayProject> projList, string fileName { #region init Items System.Data.DataTable dt = null; string ProjectSQL; int firmID; string fileName = null; string firmType = null; CRailwayFirm sItem = null; try { ProjectSQL = @"select a.*,b.ShorName,b.Latitude,b.Longitude,b.FirmTypeID, c.FirmTypeCategoryName from (select count(usrid) as num,firmid from UsrInfo where idcardno is not null group by firmid)a, (select latitude,longitude,firmid,ShorName,FirmTypeID from FirmInfo where Latitude!=0 and Longitude!=0)b, (select FirmTypeID,FirmTypeCategoryName from FirmTypeInfo where FirmTypeCategoryName='单位' or FirmTypeCategoryName='分支机构')c where a.firmid=b.FirmID and b.FirmTypeID=c.FirmTypeID"; //ProjectSQL = @"select FirmName ,a.FirmTypeID, CategoryCode, SerialNo, UpdateTime, Longitude, Latitude from (select * from FirmInfo)a, (select FirmTypeID,FirmTypeCategoryName from FirmTypeInfo)b where a.FirmTypeID=b.FirmTypeID and( FirmTypeCategoryName='单位' or FirmTypeCategoryName='分支机构') and Longitude > 10 AND Latitude > 10 order by a.FirmTypeID asc ;"; //ProjectSQL += CServerWrapper.findProjectCode(projCode) + @"%' order by ProjectID asc;"; //ProjectSQL += projCode + @"%' order by ProjectID asc;"; dt = CServerWrapper.execSqlQuery(ProjectSQL); //DatabaseWrapper.PrintDataTable(dt); foreach (DataRow dataReader in dt.Rows) { firmID = (int)dataReader["FirmTypeID"]; switch (firmID) { case 2: firmType = "施工单位"; fileName = @"施工单位.png"; break; case 5: firmType = "建设单位"; fileName = @"单位.png"; break; case 7: firmType = "制梁场"; fileName = @"LC.png"; break; case 8: firmType = "监理单位"; fileName = @"监理单位.png"; break; case 10: firmType = "项目部"; fileName = @"工程.png"; break; } sItem = new CRailwayFirm(this, Convert.ToInt32(dataReader["Num"]), Convert.ToInt32(dataReader["firmid"]), dataReader["ShorName"].ToString(), Convert.ToDouble(dataReader["Longitude"]), Convert.ToDouble(dataReader["Latitude"]), firmType, fileName); //sItem = new CRailwayFirm(this, firmType, dataReader["FirmName"].ToString(), dataReader["SerialNo"].ToString(), (DateTime)dataReader["UpdateTime"], // Convert.ToDouble(dataReader["Longitude"]), Convert.ToDouble(dataReader["Latitude"]), fileName); mFirmList.Add(sItem); if (sItem.GlobalMileage > 0) { mTotalSpotList.Add(sItem); } } //System.Console.WriteLine("readok"); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } #endregion }
private void initProjectsFromServer() { #region init Items //DataSet ds = null; System.Data.DataTable dt = null; string ProjectSQL = @"SELECT ProjectID, ProjectName, ProfessionalName, ProfessionalCategoryCode, ShorName,Mileage_Start,Mileage_Mid, Mileage_End, MileagePrefix , SerialNo, UpdateTime, Direction , avgProgress, ParentID from vw_ProjectInfo where ProfessionalCategoryCode like '-1-42-26-%' OR ProfessionalCategoryCode like '-1-42-27-%' OR ProfessionalCategoryCode like '-1-42-28-%' order by ProjectID asc;"; //string[] professionalCateCode = { "-1-42-26-", "-1-42-28-", "-1-42-27-" }; // 桥梁,路基,涵洞 string projectName, professionalName, ProfessionalCategoryCode, ShorName; int projID, parentID; double Mileage_Start, Mileage_End, Mileage_Mid; string dkCode, SerialNo; DateTime UpdateTime; double Direction, avgProgress; CRailwayProject sItem = null; try { // if (isTunnel) // ProjectSQL = @"SELECT ProjectID, ProjectName, ProfessionalName, ProfessionalCategoryCode, ShorName,Mileage_Start,Mileage_Mid, Mileage_End, // Mileage_Start_Des,Mileage_Mid_Des, Mileage_End_Des, ProjectLenth, SerialNo, UpdateTime, Direction , avgProgress, ParentID from vw_ProjectInfo where ProfessionalCategoryCode like '"; // else // ProjectSQL = @"SELECT ProjectID, ProjectName, ProfessionalName, ProfessionalCategoryCode, ShorName,Mileage_Start,Mileage_Mid, Mileage_End, // Mileage_Start_Des,Mileage_Mid_Des, Mileage_End_Des, ProjectLenth, SerialNo, UpdateTime, Direction , avgProgress, ParentID from vw_ProjectInfo where ParentID=0 AND ProfessionalCategoryCode like '"; // //ProjectSQL += CServerWrapper.findProjectCode(projCode) + @"%' order by ProjectID asc;"; // ProjectSQL += projCode + @"%' order by ProjectID asc;"; dt = CServerWrapper.execSqlQuery(ProjectSQL); //int count = dt.Rows.Count; foreach (DataRow dataReader in dt.Rows) { projID = (int)dataReader["ProjectID"]; Mileage_Start = Convert.ToDouble(dataReader["Mileage_Start"]); Mileage_Mid = Convert.ToDouble(dataReader["Mileage_Mid"]); Mileage_End = Convert.ToDouble(dataReader["Mileage_End"]); avgProgress = Convert.ToDouble(dataReader["avgProgress"]); Direction = Convert.ToDouble(dataReader["Direction"]); projectName = (string)dataReader["ProjectName"]; professionalName = (string)dataReader["ProfessionalName"]; ProfessionalCategoryCode = (string)dataReader["ProfessionalCategoryCode"]; ShorName = (string)dataReader["ShorName"]; dkCode = (string)dataReader["MileagePrefix"]; SerialNo = (string)dataReader["SerialNo"]; UpdateTime = (DateTime)dataReader["UpdateTime"]; // (DateTime)dataReader["UpdateTime"]; parentID = (int)dataReader["ProjectID"]; if (ProfessionalCategoryCode.StartsWith("-1-42-26-")) // 桥梁 { if (ProfessionalCategoryCode.StartsWith("-1-42-26-81-")) // 连续梁 { sItem = new CContBeam(this, SerialNo, projID, professionalName, projectName, ShorName, dkCode, Mileage_Start, Mileage_Mid, Mileage_End, UpdateTime, avgProgress, Direction, @"桥梁.png"); mContBeamList.Add((CContBeam)sItem); if (sItem.GlobalMileage > 0) { mTotalSpotList.Add(sItem); } } else { sItem = new CRailwayBridge(this, SerialNo, projID, professionalName, projectName, ShorName, dkCode, Mileage_Start, Mileage_Mid, Mileage_End, UpdateTime, avgProgress, Direction, @"桥梁.png"); mBridgeList.Add((CRailwayBridge)sItem); } } else if (ProfessionalCategoryCode.StartsWith("-1-42-27-")) // 隧道,涵洞 { sItem = new CRailwayTunnel(this, SerialNo, projID, professionalName, projectName, ShorName, dkCode, Mileage_Start, Mileage_Mid, Mileage_End, UpdateTime, avgProgress, Direction, @"涵洞.png"); mTunnelList.Add((CRailwayTunnel)sItem); if (sItem.GlobalMileage > 0) { mTotalSpotList.Add(sItem); } } else if (ProfessionalCategoryCode.StartsWith("-1-42-28-")) // 路基 { sItem = new CRailwayRoad(this, SerialNo, projID, professionalName, projectName, ShorName, dkCode, Mileage_Start, Mileage_Mid, Mileage_End, UpdateTime, avgProgress, Direction, @"路基.png"); mRoadList.Add((CRailwayRoad)sItem); if (sItem.GlobalMileage > 0) { mTotalSpotList.Add(sItem); } } ///没有车站表,暂时以站场路基计算,车站方向暂时位于铁路同一侧 //if (ProfessionalCategoryCode.StartsWith("-1-42-28-84-")) //-1-43-84- //if (ProfessionalCategoryCode.StartsWith(CServerWrapper.findProjectCode("giscode_station"))) //{ // int ix = projectName.IndexOf('站'); ////Console.WriteLine(projectName); // if (ix >= 0) // { // projectName = projectName.Substring(0, ix + 1); // Direction = 90; // } // sItem = new CRailwayProject(this, SerialNo, projID, professionalName, projectName, ShorName, // Mileage_Start, Mileage_Mid, Mileage_End, Mileage_Start_Des, Mileage_Mid_Des, Mileage_End_Des, UpdateTime, avgProgress, Direction, fileName, projLength); // mProjectList.Add(sItem); // //mOtherList.Add(sItem); // projList.Add(sItem); //} //else if (ProfessionalCategoryCode.StartsWith("-1-42-26-")) //{ // sItem = new CRailwayProject(this, SerialNo, projID, professionalName, projectName, ShorName, // Mileage_Start, Mileage_Mid, Mileage_End, Mileage_Start_Des, Mileage_Mid_Des, Mileage_End_Des, UpdateTime, avgProgress, Direction, @"桥梁.png", projLength); // mProjectList.Add(sItem); // mBridgeList.Add(sItem); //} //else if (ProfessionalCategoryCode.StartsWith("-1-42-28-")) //{ // sItem = new CRailwayProject(this, SerialNo, projID, professionalName, projectName, ShorName, // Mileage_Start, Mileage_Mid, Mileage_End, Mileage_Start_Des, Mileage_Mid_Des, Mileage_End_Des, UpdateTime, avgProgress, Direction, @"路基.png", projLength); // mProjectList.Add(sItem); // mRoadList.Add(sItem); //} //else if (ProfessionalCategoryCode.StartsWith("-1-42-31-")) // && projectName.EndsWith("站") // 梁厂 //{ // sItem = new CRailwayProject(this, SerialNo, projID, professionalName, projectName, ShorName, // Mileage_Start, Mileage_Mid, Mileage_End, Mileage_Start_Des, Mileage_Mid_Des, Mileage_End_Des, UpdateTime, avgProgress, Direction, @"路基.png", projLength); // mOtherList.Add(sItem); // //mStationList.Add(sItem); //} //else if (ProfessionalCategoryCode.StartsWith("-1-42-27-") || ProfessionalCategoryCode.StartsWith("-1-42-74-")) //{ // sItem = new CRailwayProject(this, SerialNo, projID, professionalName, projectName, ShorName, // Mileage_Start, Mileage_Mid, Mileage_End, Mileage_Start_Des, Mileage_Mid_Des, Mileage_End_Des, UpdateTime, avgProgress, Direction, @"涵洞.png", projLength); // mProjectList.Add(sItem); // mTunnelList.Add(sItem); //} } //System.Console.WriteLine("readok"); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } #endregion }
private void initDWProjects() { #region init Items //DataSet ds = null; string ProjectSQL; string dwName, dwModelType, dwDKCode; int projID; double dwMileage, dwLength; //string Mileage_Start_Des, Mileage_End_Des, Mileage_Mid_Des, SerialNo; DateTime dwUpdateTime; int curProjIndex = 0; System.Data.DataTable dt = null; //double Direction, avgProgress; //CRailwayProject sItem = null; //mUseLocalDB = true; //if (CServerWrapper.isConnected) //{ // ProjectSQL = @"SELECT Name, ProjectID, Mileage, ProjectLength, UpdateTime, ModelType from [Project_B_DW_Info$] where Name like '%墩' order by ProjectID asc;"; // string fileName = @"D:\GISData\jiqing\Project_B_dw_Info.xls"; // dt = DatabaseWrapper.LoadDataTableFromExcel(fileName, "Project_B_DW_Info", ProjectSQL); //} //else //{ // web service模式 //WS_GISServerData.GisDataWebServiceSoapClient ws = new WS_GISServerData.GisDataWebServiceSoapClient(); //dt = ws.ws_FindDWProjectInfo(); //string sql = @"SELECT Name, ProjectID, Mileage, ProjectLength, UpdateTime, ModelType from Project_B_DW_Info where Name like '%墩' "; //dt = CServerWrapper.findDWProjectInfo(); //dt = CServerWrapper.execSqlQuery(@"SELECT * from Project_B_DW_Info where not MileagePrefix = 'DK' and Name like '%墩' order by ProjectID asc;"); //} dt = CServerWrapper.execSqlQuery(@"SELECT Name, ProjectID, MileagePrefix, Mileage, ProjectLength, UpdateTime, ModelType, SerialNo from Project_B_DW_Info where Name like '%墩' order by ProjectID asc"); //DatabaseWrapper.PrintDataTable(dt); foreach (DataRow dataReader in dt.Rows) { try { if (!CServerWrapper.isConnected) { projID = (int)((double)dataReader["ProjectID"] + 0.1); } else { projID = (int)dataReader["ProjectID"]; } dwMileage = Convert.ToDouble(dataReader["Mileage"]); dwLength = Convert.ToDouble(dataReader["ProjectLength"]); dwName = (string)dataReader["Name"]; dwModelType = (string)dataReader["ModelType"]; dwUpdateTime = (DateTime)dataReader["UpdateTime"]; while (curProjIndex < mBridgeList.Count && projID > mBridgeList[curProjIndex].mProjectID) { curProjIndex++; } if (curProjIndex == mBridgeList.Count) { Console.WriteLine("DW_input_Error" + dwName + dwMileage); return; } mBridgeList[curProjIndex].mDWProjList.Add(new CRailwayPier(mBridgeList[curProjIndex], dataReader["Mileage"].ToString(), dwName, dwModelType, dwMileage, dwLength, dwUpdateTime, 0, dataReader["MileagePrefix"].ToString())); // Console.WriteLine(dwName +"\t"+ dwMileage); //gProType.Add("-1-43-84-", "车站"); //gProType.Add("-1-42-26-", "桥梁"); //gProType.Add("-1-42-27-", "隧道"); //gProType.Add("-1-42-28-", "区间路基"); //gProType.Add("-1-42-74-", "涵洞"); //gProType.Add("-1-42-100-", "轨道"); }//(string)dataReader["UpdateTime"], catch (System.Exception ex) { Console.WriteLine((string)dataReader["Name"] + " invalid"); } } #endregion }
/// <summary> /// 获取分项进度 /// </summary> /// <returns>返回值:分项名称,分项进度 的队列</returns> public void initFXProgress(DataTable dt1 = null, DataTable dt2 = null) { int fid; int n = 0; double avgProgress = 0; string dt; CFXProj fxp; if (dt1 != null && dt2 != null) { DataRow[] drsp = dt1.Select("ProjectID =" + mProjectID); foreach (DataRow dr in drsp) { fid = Convert.ToInt32(dr["ProjectDictID"]); fxp = new CFXProj(fid, dr["ProjectDictName"].ToString(), Convert.ToDouble(dr["DesignNum"])); fxp.initAmount = Convert.ToDouble(dr["InitNum"]); DataRow[] drs = dt2.Select("ProjectID =" + mProjectID + " and ProjectDictID = " + fid, "ReportDate asc"); if (drs.Count() == 1) { // 如果只有一条数据,无法图表显示 fxp.strDate.Add( DateTime.ParseExact(drs[0]["ReportDate"].ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).AddDays(-30).ToString("yyyyMMdd")); fxp.doneAmount.Add(0); } foreach (DataRow dr2 in drs) { fxp.strDate.Add(dr2["ReportDate"].ToString()); fxp.doneAmount.Add(Convert.ToDouble(dr2["DictTotal"])); } if (drs.Count() > 0) { dt = fxp.strDate.Last(); if (dt.CompareTo(mUpdateTime.ToString("yyyyMMdd")) > 0) // 数据库的工程表的updateDate字段逻辑有误 { mUpdateTime = DateTime.ParseExact(dt, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); } avgProgress += fxp.doneAmount.Last() / fxp.TotalAmount; } else { fxp.strDate.Add(DateTime.Now.ToString("yyyyMMdd")); fxp.doneAmount.Add(Convert.ToDouble(dr["InitNum"])); // 添加初始化量,保证每个分项工程都有数据 avgProgress += fxp.initAmount / fxp.TotalAmount; } mfx.Add(fxp); n++; } //createMFX(dlt1.Select("ProjectID =" + mProjectID) , dlt2.Select("ProjectID =" + mProjectID, "ReportDate asc")); } else if (CServerWrapper.isConnected) { DataSet ds = CServerWrapper.findProjHistory(mSerialNo); dt1 = ds.Tables[0]; dt2 = ds.Tables[1]; foreach (DataRow dr in dt1.Rows) { fid = Convert.ToInt32(dr["ProjectDictID"]); fxp = new CFXProj(fid, dr["ProjectDictName"].ToString(), Convert.ToDouble(dr["DesignNum"])); fxp.initAmount = Convert.ToDouble(dr["InitNum"]); DataRow[] drs = dt2.Select("ProjectDictID = " + fid, "ReportDate asc"); foreach (DataRow dr2 in drs) { fxp.strDate.Add(dr2["ReportDate"].ToString()); fxp.doneAmount.Add(Convert.ToDouble(dr2["DictTotal"])); } if (drs.Count() > 0) { dt = fxp.strDate.Last(); if (dt.CompareTo(mUpdateTime.ToString("yyyyMMdd")) > 0) // 数据库的工程表的updateDate字段逻辑有误 { mUpdateTime = DateTime.ParseExact(dt, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); } avgProgress += fxp.doneAmount.Last() / fxp.TotalAmount; } else { fxp.strDate.Add(DateTime.Now.ToString("yyyyMMdd")); fxp.doneAmount.Add(Convert.ToDouble(dr["InitNum"])); // 添加初始化量,保证每个分项工程都有数据 avgProgress += fxp.initAmount / fxp.TotalAmount; } mfx.Add(fxp); n++; } } if (n > 0) { avgProgress /= n; mAvgProgress = avgProgress; } else { mAvgProgress = 0; } }
/// <summary> /// 按照工点聚类,单位工程显示第一个 /// </summary> /// <returns></returns> public static void clusterConsFromWebByProj(CRailwayScene s, string dbFile, List <ConsLocation> ls, List <CHotSpot> ls2, string fromDate = null, string toDate = null, bool fromLocal = true) { double cx, cy; double tx, ty, tz, td; CRailwayLine rl; double mileage, dis, gm; bool isInside; //string fromD = DateTime.Now.AddDays(-7).ToShortDateString(); //string toD = DateTime.Now.ToShortDateString(); //dt2.Columns.Add("ProjectName", typeof(string)); //dt2.Columns.Add("DwName", typeof(string)); //dt2.Columns.Add("Longitude", typeof(double)); //dt2.Columns.Add("Latitude", typeof(double)); //dt2.Columns.Add("StaffNum", typeof(int)); // 2016-05-06 00:00:00Z //DataTable dt = CServerWrapper.findClusterConsByPDW(DateTime.Now.AddDays(-7).Date.ToString("u")); //DataTable dt = CServerWrapper.findClusterConsByPDW(fromDate, toDate); if (ls == null) { ls = new List <ConsLocation>(); } else { ls.Clear(); } if (ls2 == null) { ls2 = new List <CHotSpot>(); } else { ls2.Clear(); } DataTable dt = null; if (fromLocal) { string localPath = dbFile; dt = DatabaseWrapper.ExecuteDataTable(dbFile, @"SELECT * from ConsInfo ;"); } else if (CServerWrapper.isConnected) { dt = CServerWrapper.findClusterConsByProj(fromDate, toDate); } if (dt == null) { return; } foreach (DataRow dr in dt.Rows) { GPSAdjust.bd_decrypt(Convert.ToDouble(dr["Latitude"]), Convert.ToDouble(dr["Longitude"]), out cy, out cx); rl = CRailwayLineList.getMileagebyGPS(Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), out mileage, out dis, out isInside); CRailwayLineList.getGPSbyDKCode(rl.mDKCode, mileage, out tx, out ty, out tz, out td); s.mMainPath.getPathMileageByDKCode(rl.mDKCode, mileage, out gm, out dis); //FIXME xyn 加入两次,比较实际坐标和火星坐标的差别 //ConsLocation cl = new ConsLocation("Mars" + dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), //tx, ty, // fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"])); //ls.Add(cl); ConsLocation cl = new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), cx, cy, //Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), fromDate, toDate, Convert.ToInt32(dr["StaffNum"])); ls.Add(cl); ls2.Add(new CHotSpot(rl.mDKCode, mileage, tx, ty, tz, gm, dis, "Cons", cl)); // ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), //fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"]))); } //new StaticCluster().clusterProcess(); }
/// <summary> /// 由数据库或远程服务器读入三维中线的数据 /// </summary> /// <param name="fileName"></param> public void LoadLineListFromDB() { double[] m, x, y, z; double fromMeter, toMeter; int fromID, toID; string dkcode; int count; System.Data.DataTable dt1, dt2; dt1 = dt2 = null; //System.Data.DataTable dt3; //double[] lgt, lat; //dt3 = ExcelWrapper.LoadDataTableFromExcel(@"D:\GISData\jiqing\中线测试.xlsx", "MiddleLine", @"select Mileage, Longitude, Latitude from [MiddleLine$];"); //count = 93; //m = new double[count]; //x = new double[count]; //y = new double[count]; //z = new double[count]; //string dk = "DK"; //double meter = 0; //double startm = 1800; //int ii = 0; //foreach (DataRow dr3 in dt3.Rows) //{ // //dr2 = dt2.Rows[i]; // parseDKCode(dr3["Mileage"].ToString(), out dk, out meter); // m[ii] = meter - startm; // x[ii] = Convert.ToDouble(dr3["Longitude"]); // y[ii] = Convert.ToDouble(dr3["Latitude"]); // ii++; // //z[j] = Convert.ToDouble(dr3["Altitude"]); //} //CoordinateConverter.UTMXYToLatLonList(count,y,x,out lgt, out lat,50,false); ////UTM2GPS.GaussProjInvCal(y[0], x[0], out lgt[1], out lat[1]); //for (int i = 0; i < count; i++) //{ // Console.WriteLine("longi: {0}\t lati {1}", lgt[i], lat[i]); //} //Console.WriteLine(); if (!CServerWrapper.isConnected) { string fileName = CGisDataSettings.gDataPath + @"jiqing\MiddleLine0525.xls"; dt1 = DatabaseWrapper.LoadDataTableFromExcel(fileName, "Chain", @"select fromMeter, toMeter,fromID,toID,DKCode from [Chain$]; "); dt2 = DatabaseWrapper.LoadDataTableFromExcel(fileName, "MiddleLine", @"select Mileage, Longitude,Latitude,Altitude from [MiddleLine$]; "); ////dt1 = ds.Tables["Chain"]; ////dt2 = ds2.Tables["MiddleLine"]; } else { // ProjectService.ProjectServiceSoapClient ws = new ProjectService.ProjectServiceSoapClient(); //WS_GISServerData.GisDataWebServiceSoapClient ws = new WS_GISServerData.GisDataWebServiceSoapClient(); //dt1 = ws.ws_FindChainInfo(); //dt2 = ws.ws_FindMileageInfo(); // double mm = 100000; // double mmin ,xx,yy,zz; // double mmax, xx2,yy2,zz2; // double mx, my, mz; // string dd = "DK"; // mmin = xx = yy = zz = 0; //Mileage, Longitude, Latitude, Altitude // mx = my = mz = 0; // System.Data.DataTable dt = CServerWrapper.execSqlQuery(@"SELECT Mileage, Longitude, Latitude, Altitude //FROM MileageInfo //WHERE (MileagePrefix = '" + // dd + @"') AND ( Mileage > " + (mm - 500) + @" ) AND ( Mileage <" + (mm + 500) + @" ) ORDER BY Mileage"); // DatabaseWrapper.PrintDataTable(dt); // bool isfind = false; // foreach (DataRow dr in dt.Rows) // { // if (Convert.ToDouble(dr["Mileage"]) < mm) // { // mmin = Convert.ToDouble(dr["Mileage"]); // xx = Convert.ToDouble(dr["Longitude"]); // yy = Convert.ToDouble(dr["Latitude"]); // zz = Convert.ToDouble(dr["Altitude"]); // } // else { // isfind = true; // mmax = Convert.ToDouble(dr["Mileage"]); // xx2 = Convert.ToDouble(dr["Longitude"]); // yy2 = Convert.ToDouble(dr["Latitude"]); // zz2 = Convert.ToDouble(dr["Altitude"]); // double a = (mm - mmin) / (mmax - mmin); // mx = xx + (xx2 - xx) * a; // my = yy + (yy2 - yy) * a; // mz = zz + (zz2 - zz) * a; // } // } // Console.WriteLine(mx + "\t" + my + "\t" +mz + "\t"+ isfind); dt1 = CServerWrapper.findChainInfo(); dt2 = CServerWrapper.findMileageInfo(); //dt1 = ProjectFromServer.FindChainInfo(); //dt2 = ProjectFromServer.FindMileageInfo(); } DataRow dr2; foreach (DataRow dr in dt1.Rows) { fromMeter = (double)dr["fromMeter"]; toMeter = (double)dr["toMeter"]; if (!CServerWrapper.isConnected) { fromID = (int)((double)dr["fromID"] + 0.1); toID = (int)((double)dr["toID"] + 0.1); } else { fromID = (int)dr["fromID"]; toID = (int)dr["toID"]; } dkcode = (string)dr["DKCode"]; count = toID - fromID + 1; if (count < 2) { continue; } m = new double[count]; x = new double[count]; y = new double[count]; z = new double[count]; int j = 0; for (int i = fromID - 1; i < toID; i++, j++) { dr2 = dt2.Rows[i]; m[j] = Math.Abs((double)dr2["Mileage"] - fromMeter); x[j] = Convert.ToDouble(dr2["Longitude"]); y[j] = Convert.ToDouble(dr2["Latitude"]); z[j] = Convert.ToDouble(dr2["Altitude"]); } mLineList.Add(new CRailwayLine(dkcode, fromMeter, toMeter, false, count, m, x, y, z)); } }