コード例 #1
0
        private void InitPixelType(ComboBoxEdit cmbPixelType)
        {
            if (cmbPixelType != null)
            {
                cmbPixelType.Properties.Items.BeginUpdate();
                try
                {
                    cmbPixelType.Properties.Items.Clear();
                    Array values = Enum.GetValues(typeof(PixelType));
                    foreach (PixelType pixelType in values)
                    {
                        cmbPixelType.Properties.Items.Add(CommonAPI.GetEnumDescription(pixelType));
                    }
                    IRasterProps rasterProps = this.m_raster as IRasterProps;
                    switch (rasterProps.PixelType)
                    {
                    case rstPixelType.PT_UCHAR:
                        cmbPixelType.SelectedIndex = 0;
                        break;

                    case rstPixelType.PT_CHAR:
                        cmbPixelType.SelectedIndex = 1;
                        break;

                    case rstPixelType.PT_USHORT:
                        cmbPixelType.SelectedIndex = 2;
                        break;

                    case rstPixelType.PT_SHORT:
                        cmbPixelType.SelectedIndex = 3;
                        break;

                    case rstPixelType.PT_ULONG:
                        cmbPixelType.SelectedIndex = 4;
                        break;

                    case rstPixelType.PT_LONG:
                        cmbPixelType.SelectedIndex = 5;
                        break;

                    case rstPixelType.PT_FLOAT:
                        cmbPixelType.SelectedIndex = 6;
                        break;

                    case rstPixelType.PT_DOUBLE:
                        cmbPixelType.SelectedIndex = 7;
                        break;

                    default:
                        cmbPixelType.SelectedIndex = 0;
                        break;
                    }
                }
                finally
                {
                    cmbPixelType.Properties.Items.EndUpdate();
                }
            }
        }
コード例 #2
0
        public string login()
        {
            objUserData                   = new UserData();
            CommonAPI.LoginInfo           = objUserData;
            objUserData.uuid              = Guid.NewGuid().ToString();
            objUserData.WorkStationSerial = Tools.generateWorkStationGUID();

            SymmetricCryptography symmetricCryptography_0;            //加密器

            symmetricCryptography_0 = new SymmetricCryptography(SymmetricProvider.Rijndael);
            byte[] key = null;
            byte[] iV  = null;

            //系统默认是根据uuid 生成一个算法key的,或者简单理解为uuid就是加密和解密的密码
            CommonAPI.GenerateKey(objUserData.uuid, ref key, ref iV, SymmetricProvider.Rijndael);
            symmetricCryptography_0.Key = key;
            symmetricCryptography_0.IV  = iV;


            objUserData.UserId     = symmetricCryptography_0.EncryptString(m_strUser);         //demo
            objUserData.Password   = symmetricCryptography_0.EncryptString(m_strPassword);     //DEMO
            objUserData.AppServer  = m_strServer;
            objUserData.LanguageID = "zh-CN";
            objUserData.cSubID     = "DP";
            objUserData.operDate   = m_strDate;

            objUserData.DataSource = m_strDataSource;

            Debugger.Log(0, null, UserDataTools.userData2String(objUserData));
            var paras       = new CommonParameters();
            var loginHeader = new LoginedDataHead();

            loginHeader.ChangePwd          = false;
            loginHeader.KickOutWorkStation = false;
            loginHeader.NewPassword        = symmetricCryptography_0.EncryptString("");     //DEMO

            paras.Para1 = "TARGET\\ENTERPRISEPORTAL.EXE";
            paras.Para2 = true;
            paras.Para3 = loginHeader;

            try {
                credit.BFDispatch("Authenticate", objUserData, ref paras);

                if (!string.IsNullOrEmpty(paras.Para1))
                {
                    return(paras.Para1);
                }
            } catch (CustomError cEx) {
                //MessageBox.Show(cEx.Message);
                throw;
            } finally {
            }
        }
コード例 #3
0
        /// <summary>
        /// Create a new Common API logger using the default logging delegates.
        /// </summary>
        /// <param name="CommonAPI">An Common API.</param>
        /// <param name="Context">A context of this API.</param>
        /// <param name="LogFileCreator">A delegate to create a log file from the given context and log file name.</param>
        public CommonAPILogger(CommonAPI CommonAPI,
                               String Context = DefaultContext,
                               LogfileCreatorDelegate LogFileCreator = null)

            : this(CommonAPI,
                   Context,
                   null,
                   null,
                   null,
                   null,
                   LogFileCreator : LogFileCreator)

        {
        }
コード例 #4
0
 //
 //主窗体关闭保存最近历史
 //
 private void MainFormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         history.SaveHistory();
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message);
         Log.WriteLog(typeof(GFSApplication), ex);
     }
     try
     { CommonAPI.DelectDir(ConstDef.PATH_TEMP); }
     catch (Exception)
     { }
 }
コード例 #5
0
        /// <summary>
        /// Create a new Common API logger using the default logging delegates.
        /// </summary>
        /// <param name="CommonAPI">An Common API.</param>
        /// <param name="Context">A context of this API.</param>
        /// <param name="LogFileCreator">A delegate to create a log file from the given context and log file name.</param>
        public CommonAPILogger(CommonAPI CommonAPI,
                               String LoggingPath,
                               String?Context = DefaultContext,
                               LogfileCreatorDelegate?LogFileCreator = null)

            : this(CommonAPI,
                   LoggingPath,
                   Context ?? DefaultContext,
                   null,
                   null,
                   null,
                   null,
                   LogFileCreator : LogFileCreator)

        {
        }
コード例 #6
0
 internal static void SetupWebView <TApi>(this WebView webView, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi)
 {
     webView.IsHistoryDisabled          = true;
     webView.AllowDeveloperTools        = true;
     webView.DisableBuiltinContextMenus = true;
     //webView.BeforeResourceLoad += WebViewExtensions.OnWebViewBeforeResourceLoad;
     webView.AddBeforeResourceLoadEvent(WebViewExtensions.OnWebViewBeforeResourceLoad);
     webView.DefaultScriptsExecutionTimeout = (HybridConfiguration.DisableWebViewExecutionTimeouts ? null : new TimeSpan?(WebViewExtensions.DefaultScriptExecutionTimeout));
     //webView.FindLogicalParent<IDisposable>().MustBeSet("The webview must belong to a IDisposable view and be disposed");
     if (HybridConfiguration.ShowDeveloperTools)
     {
         webView.ShowDeveloperTools();
     }
     jsCtx       = new DocumentReadyJSApi(webView);
     jsApi       = newJsApi(jsCtx);
     jsCommonApi = new CommonAPI(jsCtx);
 }
コード例 #7
0
        //导出当前页
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            saveFileDialog1.Filter = "Excel 2007文档(*.xlsx)|*.xlsx|Excel 2003文档(*.xls)|*.xls" +
                                     "|csv文件(*.csv)|*.csv|文本文件(*.txt)|*.txt";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                DataTable exportTable  = null;
                string    exportPath   = saveFileDialog1.FileName;
                string    exportFormat = (new System.IO.FileInfo(exportPath)).Extension;
                if (ctrlAttrubuteGrid1.PageTag == 0)
                {
                    exportTable = (DataTable)ctrlAttrubuteGrid1.AllDataGrid.DataSource;
                }
                else
                {
                    exportTable = (DataTable)ctrlAttrubuteGrid1.SelectionDataGrid.DataSource;
                }
                exportTable = exportTable.Copy();
                if (exportTable.Columns.Contains("选中要素"))
                {
                    exportTable.Columns.Remove("选中要素");
                }
                switch (exportFormat)
                {
                case ".xlsx":
                    CommonAPI.ExportDataTableToXLSX(exportTable, exportPath);
                    break;

                case ".xls":
                    CommonAPI.ExportDataTableToXLS(exportTable, exportPath);
                    break;

                case ".csv":
                    CommonAPI.ExportDataTableToCSV(exportTable, exportPath);
                    break;

                case ".txt":
                    CommonAPI.DataTableExportToTxt(exportPath, exportTable);
                    break;
                }
                XtraMessageBox.Show("导出成功!");
            }
        }
コード例 #8
0
        protected OCPIRequest(HTTPRequest Request,
                              CommonAPI CommonAPI)
        {
            this.HTTPRequest = Request ?? throw new ArgumentNullException(nameof(HTTPRequest), "The given HTTP request must not be null!");

            this.RequestId       = Request.TryParseHeaderField <Request_Id>    ("X-Request-ID", Request_Id.TryParse) ?? Request_Id.Random(IsLocal: true);
            this.CorrelationId   = Request.TryParseHeaderField <Correlation_Id>("X-Correlation-ID", Correlation_Id.TryParse) ?? Correlation_Id.Random(IsLocal: true);
            this.ToCountryCode   = Request.TryParseHeaderField <CountryCode>   ("OCPI-to-country-code", CountryCode.TryParse);
            this.ToPartyId       = Request.TryParseHeaderField <Party_Id>      ("OCPI-to-party-id", Party_Id.TryParse);
            this.FromCountryCode = Request.TryParseHeaderField <CountryCode>   ("OCPI-from-country-code", CountryCode.TryParse);
            this.FromPartyId     = Request.TryParseHeaderField <Party_Id>      ("OCPI-from-party-id", Party_Id.TryParse);


            if (Request.Authorization is HTTPTokenAuthentication TokenAuth &&
                TokenAuth.Token.TryBase64Decode_UTF8(out String DecodedToken) &&
                OCPIv2_2.AccessToken.TryParse(DecodedToken, out AccessToken accessToken))
            {
                this.AccessToken = accessToken;
            }
コード例 #9
0
        private void InitResamplingMethod(ComboBoxEdit cmbResamplingType)
        {
            if (cmbResamplingType != null)
            {
                cmbResamplingType.Properties.Items.BeginUpdate();
                try
                {
                    cmbResamplingType.Properties.Items.Clear();
                    Array values = Enum.GetValues(typeof(ResamplingMethod));
                    foreach (ResamplingMethod resamplingMethod in values)
                    {
                        cmbResamplingType.Properties.Items.Add(CommonAPI.GetEnumDescription(resamplingMethod));
                    }
                    switch (this.m_raster.ResampleMethod)
                    {
                    case rstResamplingTypes.RSP_NearestNeighbor:
                        cmbResamplingType.SelectedIndex = 0;
                        break;

                    case rstResamplingTypes.RSP_BilinearInterpolation:
                        cmbResamplingType.SelectedIndex = 1;
                        break;

                    case rstResamplingTypes.RSP_CubicConvolution:
                        cmbResamplingType.SelectedIndex = 2;
                        break;

                    case rstResamplingTypes.RSP_Majority:
                        cmbResamplingType.SelectedIndex = 3;
                        break;

                    default:
                        cmbResamplingType.SelectedIndex = 0;
                        break;
                    }
                }
                finally
                {
                    cmbResamplingType.Properties.Items.EndUpdate();
                }
            }
        }
コード例 #10
0
 private void InitOutputType(ComboBoxEdit cmbOutputType)
 {
     if (cmbOutputType != null)
     {
         cmbOutputType.Properties.Items.BeginUpdate();
         try
         {
             cmbOutputType.Properties.Items.Clear();
             Array values = Enum.GetValues(typeof(RasterFormat));
             foreach (RasterFormat rasterFormat in values)
             {
                 cmbOutputType.Properties.Items.Add(CommonAPI.GetEnumDescription(rasterFormat));
             }
             cmbOutputType.SelectedIndex = 0;
         }
         finally
         {
             cmbOutputType.Properties.Items.EndUpdate();
         }
     }
 }
コード例 #11
0
        public DBWorkThread(int i_type)
        {
            if (DBUrl.SERVERMODE)
            {
                string   cONNECT_STRING = DBUrl.CONNECT_STRING;
                string[] array          = cONNECT_STRING.Split(new string[]
                {
                    ","
                }, StringSplitOptions.RemoveEmptyEntries);
                this.con = new MySqlConnection(string.Concat(new string[]
                {
                    "Database=eco",
                    DBUrl.SERVERID,
                    ";Data Source=",
                    array[0],
                    ";Port=",
                    array[1],
                    ";User Id=",
                    array[2],
                    ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=50;Default Command Timeout=0;charset=utf8;"
                }));
                this.con.Open();
            }
            else
            {
                this.DBTYPE = i_type;
                switch (this.DBTYPE)
                {
                case 0:
                    break;

                case 1:
                    try
                    {
                        this.con = new MySqlConnection(string.Concat(new object[]
                        {
                            "Database=",
                            DBUrl.DB_CURRENT_NAME,
                            ";Data Source=",
                            DBUrl.CURRENT_HOST_PATH,
                            ";Port=",
                            DBUrl.CURRENT_PORT,
                            ";User Id=",
                            DBUrl.CURRENT_USER_NAME,
                            ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;"
                        }));
                        this.con.Open();
                        DebugCenter.GetInstance().clearStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                        goto IL_25B;
                    }
                    catch (Exception e)
                    {
                        DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                        DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e, false, "    "));
                        goto IL_25B;
                    }
                    break;

                default:
                    goto IL_25B;
                }
                try
                {
                    int num = 0;
                    while (TaskStatus.GetDBStatus() == -1 && num < 600)
                    {
                        Thread.Sleep(50);
                        DebugCenter.GetInstance().appendToFile(this.ToString() + "Waiting DBConnection : " + num);
                        num++;
                    }
                    DBConn dynaConnection = DBConnPool.getDynaConnection();
                    if (dynaConnection != null)
                    {
                        this.con = dynaConnection.con;
                    }
                    else
                    {
                        this.con = null;
                    }
                }
                catch (Exception ex)
                {
                    DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                }
            }
IL_25B:
            this.debug = DebugCenter.GetInstance();
        }
コード例 #12
0
ファイル: AppData.cs プロジェクト: Jackjet/ECOSingle
        public static void LoadPUEData(ref double[] ret_v, ref int[] DB_Flg, ref string[] strTimePrompt)
        {
            try
            {
                int iSGFlag     = Sys_Para.GetISGFlag();
                int iTPowerFlag = Sys_Para.GetITPowerFlag();
                DB_Flg[0] = iSGFlag;
                DB_Flg[1] = iTPowerFlag;
                if (iSGFlag != 0)
                {
                    DateTime now  = DateTime.Now;
                    double   num  = 0.0;
                    double   num2 = 0.0;
                    List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay();
                    foreach (InSnergyGateway current in allGateWay)
                    {
                        if (InSnergyService.IsGatewayOnlineEx(current.GatewayID))
                        {
                            foreach (Branch current2 in current.BranchList)
                            {
                                if (InSnergyService.IsBranchOnlineEx(current2.GatewayID, current2.BranchID))
                                {
                                    Dictionary <string, IMeter> branchEx = InSnergyService.GetBranchEx(current.GatewayID, current2.BranchID);
                                    foreach (SubMeter current3 in current2.SubMeterList)
                                    {
                                        if (branchEx.ContainsKey(current3.SubmeterID) && current3.ElectricityUsage != 0)
                                        {
                                            IMeter meter = branchEx[current3.SubmeterID];
                                            switch (current3.ElectricityUsage)
                                            {
                                            case 1:
                                                if (meter.listParam.ContainsKey(5))
                                                {
                                                    double dvalue = meter.listParam[5].dvalue;
                                                    num += dvalue;
                                                }
                                                break;

                                            case 2:
                                                if (meter.listParam.ContainsKey(5))
                                                {
                                                    double dvalue = meter.listParam[5].dvalue;
                                                    num2 += dvalue;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    double num3;
                    if (iTPowerFlag == 1)
                    {
                        num3 = num;
                    }
                    else
                    {
                        num3 = num;
                    }
                    double num4 = num3 + num2;
                    ret_v[0]         = num3;
                    ret_v[1]         = num4;
                    strTimePrompt[0] = "";
                    strTimePrompt[1] = "";
                    if (InSnergyGateway.Need_Calculate_PUE)
                    {
                        DebugCenter.GetInstance().appendToFile("^^^ Begin to update PUE data ");
                        DateTime now2 = DateTime.Now;
                        num  = InSnergyGateway.GetPUE(0);
                        num2 = InSnergyGateway.GetPUE(1);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(0);
                            num3 = dataCenterPDSum + num;
                        }
                        num4                         = num3 + num2;
                        ret_v[2]                     = num3;
                        ret_v[3]                     = num4;
                        strTimePrompt[2]             = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[3]             = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_HOUR = num3;
                        InSnergyGateway.Last_TT_HOUR = num4;
                        num  = InSnergyGateway.GetPUE(2);
                        num2 = InSnergyGateway.GetPUE(3);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(1);
                            num3 = dataCenterPDSum + num;
                        }
                        num4                        = num3 + num2;
                        ret_v[4]                    = num3;
                        ret_v[5]                    = num4;
                        strTimePrompt[4]            = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[5]            = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_DAY = num3;
                        InSnergyGateway.Last_TT_DAY = num4;
                        num  = InSnergyGateway.GetPUE(4);
                        num2 = InSnergyGateway.GetPUE(5);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(2);
                            num3 = dataCenterPDSum + num;
                        }
                        num4     = num3 + num2;
                        ret_v[6] = num3;
                        ret_v[7] = num4;
                        DateTime dateTime = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d"))));
                        if (now.DayOfWeek == DayOfWeek.Sunday)
                        {
                            dateTime = dateTime.AddDays(-7.0);
                        }
                        DateTime dateTime2 = dateTime.AddDays(6.0);
                        strTimePrompt[6]                   = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[7]                   = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_WEEK       = num3;
                        InSnergyGateway.Last_TT_WEEK       = num4;
                        InSnergyGateway.Need_Calculate_PUE = false;
                        DebugCenter.GetInstance().appendToFile("^^^^ Finish to update PUE data " + (DateTime.Now - now2).TotalSeconds + " sec");
                    }
                    else
                    {
                        ret_v[2]         = InSnergyGateway.Last_IT_HOUR;
                        ret_v[3]         = InSnergyGateway.Last_TT_HOUR;
                        ret_v[4]         = InSnergyGateway.Last_IT_DAY;
                        ret_v[5]         = InSnergyGateway.Last_TT_DAY;
                        ret_v[6]         = InSnergyGateway.Last_IT_WEEK;
                        ret_v[7]         = InSnergyGateway.Last_TT_WEEK;
                        strTimePrompt[2] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[4] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        DateTime dateTime3 = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d"))));
                        if (now.DayOfWeek == DayOfWeek.Sunday)
                        {
                            dateTime3 = dateTime3.AddDays(-7.0);
                        }
                        DateTime dateTime4 = dateTime3.AddDays(6.0);
                        strTimePrompt[6] = dateTime3.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime4.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[3] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[5] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[7] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                string str = CommonAPI.ReportException(0, ex, true, "    ");
                Common.WriteLine("LoadPUEData: " + ex.Message + "\r\n" + str, new string[0]);
            }
        }
コード例 #13
0
        private bool LoadROI(string inSample, out string msg)
        {
            try
            {
                msg = "";
                if (roiLayerDic.Count > 0)
                {
                    roiLayerDic.Clear();
                }
                if (!string.IsNullOrEmpty(inSample) && File.Exists(inSample))
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(inSample);
                    XmlNode xmlNode = xmlDocument.SelectSingleNode("RegionsOfInterest");
                    if (xmlNode == null)
                    {
                        msg = "ROI内容为空!";
                        return(false);
                    }
                    for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                    {
                        XmlNode  xmlNode2 = xmlNode.ChildNodes[i];
                        string   value    = xmlNode2.Attributes[0].Value;
                        string   value2   = xmlNode2.Attributes[1].Value;
                        string[] array    = value2.Split(new char[]
                        {
                            ','
                        });
                        int       red   = CommonAPI.ConvertToInt(array[0]);
                        int       green = CommonAPI.ConvertToInt(array[1]);
                        int       blue  = CommonAPI.ConvertToInt(array[2]);
                        IRgbColor color = new RgbColorClass
                        {
                            Red   = red,
                            Green = green,
                            Blue  = blue
                        };
                        ROILayerClass rOILayerClass = new ROILayerClass();
                        rOILayerClass.ID          = ((roiLayerDic.Keys.Count == 0) ? 1 : (roiLayerDic.Keys.Max() + 1));
                        rOILayerClass.Name        = value;
                        rOILayerClass.Color       = color;
                        rOILayerClass.ElementList = new List <ROIElementClass>();
                        roiLayerDic.Add(rOILayerClass.ID, rOILayerClass);

                        string innerText = xmlNode2.SelectSingleNode("GeometryDef/CoordSysStr").InnerText;
                        spatialReference = EngineAPI.GetSpatialRefFromPrjStr(innerText);
                        XmlNodeList xmlNodeList = xmlNode2.SelectNodes("GeometryDef/Polygon/Exterior/LinearRing/Coordinates");
                        for (int j = 0; j < xmlNodeList.Count; j++)
                        {
                            IPointCollection pointCollection = new PolygonClass();
                            string           innerText2      = xmlNodeList[j].InnerText;
                            string[]         array2          = innerText2.Split(new char[]
                            {
                                ' '
                            });
                            int num = array2.Length / 2;
                            for (int k = 0; k < num; k++)
                            {
                                IPoint point = new PointClass();
                                double x     = CommonAPI.ConvertToDouble(array2[2 * k]);
                                double y     = CommonAPI.ConvertToDouble(array2[2 * k + 1]);
                                point.PutCoords(x, y);
                                object value3 = Missing.Value;
                                object value4 = Missing.Value;
                                pointCollection.AddPoint(point, ref value3, ref value4);
                            }
                            IPolygon polygon = pointCollection as IPolygon;
                            polygon.FromPoint = pointCollection.get_Point(0);
                            polygon.ToPoint   = pointCollection.get_Point(pointCollection.PointCount - 1);
                            if (spatialReference == null)
                            {
                                spatialReference = new UnknownCoordinateSystemClass();
                            }
                            polygon.SpatialReference = spatialReference;
                            polygon.Close();
                            IElement element = new PolygonElementClass();
                            element.Geometry = polygon;

                            ROIElementClass rOIElementClass = new ROIElementClass
                            {
                                Element = element,
                                Checked = true
                            };
                            rOILayerClass.ElementList.Add(rOIElementClass);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(false);
            }
        }
コード例 #14
0
 public QuanLyVanTaiController()
 {
     commonAPI     = new CommonAPI();
     urlAPIDanhMuc = new UrlAPIDanhMuc();
 }
コード例 #15
0
ファイル: UserDataTools.cs プロジェクト: zzlufida/MiniU8Login
        // UFSoft.U8.Framework.Login.UI.clsLogin
        public static UserData DeUserData(string cryptuuid, string s, string string_17)
        {
            UserData userData = null;

            if (s.Length != 0)
            {
                byte[] iV  = null;
                byte[] key = null;
                SymmetricCryptography symm = new SymmetricCryptography(SymmetricProvider.Rijndael);
                CommonAPI.GenerateKey(cryptuuid, ref key, ref iV, SymmetricProvider.Rijndael);
                symm.Key = key;
                symm.IV  = iV;
                StringReader  stringReader  = new StringReader(s);
                XmlTextReader xmlTextReader = CustomTypeAlias.CreateXmlReader(stringReader);
                userData = new UserData();
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.LocalName == "Entry")
                    {
                        userData.UserId            = symm.DecryptString(xmlTextReader.GetAttribute("user"));
                        userData.Password          = symm.DecryptString(xmlTextReader.GetAttribute("data"));
                        userData.AccID             = symm.DecryptString(xmlTextReader.GetAttribute("accid"));
                        userData.AppServer         = symm.DecryptString(xmlTextReader.GetAttribute("appserver"));
                        userData.cSubID            = symm.DecryptString(xmlTextReader.GetAttribute("subid"));
                        userData.iYear             = symm.DecryptString(xmlTextReader.GetAttribute("iyear"));
                        userData.ConnString        = symm.DecryptString(xmlTextReader.GetAttribute("connstring"));
                        userData.operDate          = symm.DecryptString(xmlTextReader.GetAttribute("operdate"));
                        userData.DataSource        = symm.DecryptString(xmlTextReader.GetAttribute("datasource"));
                        userData.LanguageID        = symm.DecryptString(xmlTextReader.GetAttribute("languageid"));
                        userData.WorkStationSerial = symm.DecryptString(xmlTextReader.GetAttribute("workstationserial"));
                        userData.RightServer       = symm.DecryptString(xmlTextReader.GetAttribute("rightserver"));
                        userData.IsCompanyVer      = bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("iscompanyver")));
                        userData.SecondConnString  = (Hashtable)CustomXmlSerializer.Deserialize(symm.DecryptString(xmlTextReader.GetAttribute("secondconnstring")), "Hashtable");
                        userData.EmployeeId        = symm.DecryptString(xmlTextReader.GetAttribute("employeeid"));
                        userData.IsAdmin           = bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("isadmin")));
                        userData.UserName          = symm.DecryptString(xmlTextReader.GetAttribute("username"));
                        userData.AccName           = symm.DecryptString(xmlTextReader.GetAttribute("accname"));
                        userData.EntTypeID         = symm.DecryptString(xmlTextReader.GetAttribute("enttypeid"));
                        userData.iMonth            = int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("imonth")));
                        userData.AppServerSerial   = symm.DecryptString(xmlTextReader.GetAttribute("appServerserial"));
                        userData.Roles             = symm.DecryptString(xmlTextReader.GetAttribute("roles"));
                        userData.ProtocolPort      = (Hashtable)CustomXmlSerializer.Deserialize(symm.DecryptString(xmlTextReader.GetAttribute("protocolport")), "protocolport");
                        userData.BarCode           = symm.DecryptString(xmlTextReader.GetAttribute("barcode"));
                        userData.Customer          = symm.DecryptString(xmlTextReader.GetAttribute("customer"));
                        userData.AuthenMode        = int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("authenmode")));
                        userData.AuthenExtraInfo   = symm.DecryptString(xmlTextReader.GetAttribute("authenextrainfo"));
                        userData.IndustryType      = symm.DecryptString(xmlTextReader.GetAttribute("industrytype"));
                        userData.iBeginYear        = symm.DecryptString(xmlTextReader.GetAttribute("ibeginyear"));
                        userData.AIOServer         = symm.DecryptString(xmlTextReader.GetAttribute("aiosrv"));

                        if (xmlTextReader.GetAttribute("crmsrv") != null && FIELDMAP.ContainsKey("CrmServer"))
                        {
                            //userData.CrmServer = symm.DecryptString(xmlTextReader.GetAttribute("crmsrv"));

                            FIELDMAP["CrmServer"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("crmsrv")));
                        }


                        if (xmlTextReader.GetAttribute("utusrv") != null && FIELDMAP.ContainsKey("UTUServer"))
                        {
                            //userData.UTUServer = symm.DecryptString(xmlTextReader.GetAttribute("utusrv"));

                            FIELDMAP["UTUServer"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("utusrv")));
                        }


                        if (xmlTextReader.GetAttribute("remind") != null && FIELDMAP.ContainsKey("isRemind"))
                        {
                            FIELDMAP["isRemind"].SetValue(userData, bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("remind"))));
                        }
                        if (xmlTextReader.GetAttribute("usermode") != null && FIELDMAP.ContainsKey("UserMode"))
                        {
                            FIELDMAP["UserMode"].SetValue(userData, int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("usermode"))));
                        }
                        if (xmlTextReader.GetAttribute("sps") != null && FIELDMAP.ContainsKey("ValidateSPS"))
                        {
                            FIELDMAP["ValidateSPS"].SetValue(userData, bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("sps"))));
                        }
                        if (xmlTextReader.GetAttribute("sysdate") != null && FIELDMAP.ContainsKey("sysdate"))
                        {
                            FIELDMAP["sysdate"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("sysdate")));
                        }

                        if (string.IsNullOrEmpty(string_17))
                        {
                            userData.Auditor = new AuditorContext {
                                AuditorId   = userData.UserId,
                                AuditorName = userData.UserName
                            };
                        }
                        else
                        {
                            userData.Auditor = (AuditorContext)CustomXmlSerializer.Deserialize(symm.DecryptString(string_17), "AuditorContext");
                        }

                        xmlTextReader.Close();
                        stringReader.Close();
                    }
                }
            }
            userData.uuid = cryptuuid;
            return(userData);
        }
コード例 #16
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="client">操作类</param>
 public CommonInterface(Client client)
     : base(client)
 {
     api = new CommonAPI(client);
 }
コード例 #17
0
        /// <summary>
        /// Create a new Common API logger using the given logging delegates.
        /// </summary>
        /// <param name="CommonAPI">An Common API.</param>
        /// <param name="Context">A context of this API.</param>
        ///
        /// <param name="LogHTTPRequest_toConsole">A delegate to log incoming HTTP requests to console.</param>
        /// <param name="LogHTTPResponse_toConsole">A delegate to log HTTP requests/responses to console.</param>
        /// <param name="LogHTTPRequest_toDisc">A delegate to log incoming HTTP requests to disc.</param>
        /// <param name="LogHTTPResponse_toDisc">A delegate to log HTTP requests/responses to disc.</param>
        ///
        /// <param name="LogHTTPRequest_toNetwork">A delegate to log incoming HTTP requests to a network target.</param>
        /// <param name="LogHTTPResponse_toNetwork">A delegate to log HTTP requests/responses to a network target.</param>
        /// <param name="LogHTTPRequest_toHTTPSSE">A delegate to log incoming HTTP requests to a HTTP server sent events source.</param>
        /// <param name="LogHTTPResponse_toHTTPSSE">A delegate to log HTTP requests/responses to a HTTP server sent events source.</param>
        ///
        /// <param name="LogHTTPError_toConsole">A delegate to log HTTP errors to console.</param>
        /// <param name="LogHTTPError_toDisc">A delegate to log HTTP errors to disc.</param>
        /// <param name="LogHTTPError_toNetwork">A delegate to log HTTP errors to a network target.</param>
        /// <param name="LogHTTPError_toHTTPSSE">A delegate to log HTTP errors to a HTTP server sent events source.</param>
        ///
        /// <param name="LogFileCreator">A delegate to create a log file from the given context and log file name.</param>
        public CommonAPILogger(CommonAPI CommonAPI,
                               String Context,

                               OCPIRequestLoggerDelegate LogHTTPRequest_toConsole,
                               OCPIResponseLoggerDelegate LogHTTPResponse_toConsole,
                               OCPIRequestLoggerDelegate LogHTTPRequest_toDisc,
                               OCPIResponseLoggerDelegate LogHTTPResponse_toDisc,

                               OCPIRequestLoggerDelegate LogHTTPRequest_toNetwork   = null,
                               OCPIResponseLoggerDelegate LogHTTPResponse_toNetwork = null,
                               OCPIRequestLoggerDelegate LogHTTPRequest_toHTTPSSE   = null,
                               OCPIResponseLoggerDelegate LogHTTPResponse_toHTTPSSE = null,

                               OCPIResponseLoggerDelegate LogHTTPError_toConsole = null,
                               OCPIResponseLoggerDelegate LogHTTPError_toDisc    = null,
                               OCPIResponseLoggerDelegate LogHTTPError_toNetwork = null,
                               OCPIResponseLoggerDelegate LogHTTPError_toHTTPSSE = null,

                               LogfileCreatorDelegate LogFileCreator = null)

            : base(CommonAPI.HTTPServer,
                   Context,

                   LogHTTPRequest_toConsole,
                   LogHTTPResponse_toConsole,
                   LogHTTPRequest_toDisc,
                   LogHTTPResponse_toDisc,

                   LogHTTPRequest_toNetwork,
                   LogHTTPResponse_toNetwork,
                   LogHTTPRequest_toHTTPSSE,
                   LogHTTPResponse_toHTTPSSE,

                   LogHTTPError_toConsole,
                   LogHTTPError_toDisc,
                   LogHTTPError_toNetwork,
                   LogHTTPError_toHTTPSSE,

                   LogFileCreator)

        {
            this.CommonAPI = CommonAPI ?? throw new ArgumentNullException(nameof(CommonAPI), "The given Common API must not be null!");

            #region Credentials

            RegisterEvent("PostCredentialsRequest",
                          handler => CommonAPI.OnPostCredentialsRequest += handler,
                          handler => CommonAPI.OnPostCredentialsRequest -= handler,
                          "Credentials", "Request", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);

            RegisterEvent("PostCredentialsResponse",
                          handler => CommonAPI.OnPostCredentialsResponse += handler,
                          handler => CommonAPI.OnPostCredentialsResponse -= handler,
                          "Credentials", "Response", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);


            RegisterEvent("PutCredentialsRequest",
                          handler => CommonAPI.OnPutCredentialsRequest += handler,
                          handler => CommonAPI.OnPutCredentialsRequest -= handler,
                          "Credentials", "Request", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);

            RegisterEvent("PutCredentialsResponse",
                          handler => CommonAPI.OnPutCredentialsResponse += handler,
                          handler => CommonAPI.OnPutCredentialsResponse -= handler,
                          "Credentials", "Response", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);


            RegisterEvent("DeleteCredentialsRequest",
                          handler => CommonAPI.OnDeleteCredentialsRequest += handler,
                          handler => CommonAPI.OnDeleteCredentialsRequest -= handler,
                          "Credentials", "Request", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);

            RegisterEvent("DeleteCredentialsResponse",
                          handler => CommonAPI.OnDeleteCredentialsResponse += handler,
                          handler => CommonAPI.OnDeleteCredentialsResponse -= handler,
                          "Credentials", "Response", "All").
            RegisterDefaultConsoleLogTarget(this).
            RegisterDefaultDiscLogTarget(this);

            #endregion
        }
コード例 #18
0
        /// <summary>
        /// Add a method callback for the given URL template.
        /// </summary>
        /// <param name="CommonAPI">The OCPI Common API.</param>
        /// <param name="Hostname">The HTTP hostname.</param>
        /// <param name="HTTPMethod">The HTTP method.</param>
        /// <param name="URLTemplate">The URL template.</param>
        /// <param name="HTTPContentType">The HTTP content type.</param>
        /// <param name="URLAuthentication">Whether this method needs explicit uri authentication or not.</param>
        /// <param name="HTTPMethodAuthentication">Whether this method needs explicit HTTP method authentication or not.</param>
        /// <param name="ContentTypeAuthentication">Whether this method needs explicit HTTP content type authentication or not.</param>
        /// <param name="OCPIRequestLogger">A OCPI request logger.</param>
        /// <param name="OCPIResponseLogger">A OCPI response logger.</param>
        /// <param name="DefaultErrorHandler">The default error handler.</param>
        /// <param name="OCPIRequestHandler">The method to call.</param>
        public static void AddOCPIMethod(this CommonAPI CommonAPI,
                                         HTTPHostname Hostname,
                                         HTTPMethod HTTPMethod,
                                         HTTPPath URLTemplate,
                                         HTTPContentType HTTPContentType              = null,
                                         HTTPAuthentication URLAuthentication         = null,
                                         HTTPAuthentication HTTPMethodAuthentication  = null,
                                         HTTPAuthentication ContentTypeAuthentication = null,
                                         OCPIRequestLogHandler OCPIRequestLogger      = null,
                                         OCPIResponseLogHandler OCPIResponseLogger    = null,
                                         HTTPDelegate DefaultErrorHandler             = null,
                                         OCPIRequestDelegate OCPIRequestHandler       = null,
                                         URLReplacement AllowReplacement              = URLReplacement.Fail)

        {
            CommonAPI.HTTPServer.
            AddMethodCallback(Hostname,
                              HTTPMethod,
                              URLTemplate,
                              HTTPContentType,
                              URLAuthentication,
                              HTTPMethodAuthentication,
                              ContentTypeAuthentication,
                              (timestamp, httpAPI, httpRequest) => OCPIRequestLogger?.Invoke(timestamp, null, HTTP.OCPIRequest.Parse(httpRequest, CommonAPI)),
                              (timestamp, httpAPI, httpRequest, httpResponse) => OCPIResponseLogger?.Invoke(timestamp, null, httpRequest.SubprotocolRequest  as OCPIRequest,
                                                                                                            (httpResponse.SubprotocolResponse as OCPIResponse)
                                                                                                            ?? new OCPIResponse(httpRequest.SubprotocolRequest as OCPIRequest,
                                                                                                                                2000,
                                                                                                                                "OCPIResponse is null!",
                                                                                                                                httpResponse.HTTPBodyAsUTF8String,
                                                                                                                                httpResponse.Timestamp,
                                                                                                                                httpResponse)),
                              DefaultErrorHandler,
                              async httpRequest => {
                try
                {
                    // When no OCPIRequestLogger was used!
                    if (httpRequest.SubprotocolRequest is null)
                    {
                        httpRequest.SubprotocolRequest = OCPIRequest.Parse(httpRequest, CommonAPI);
                    }

                    var OCPIResponseBuilder = await OCPIRequestHandler(httpRequest.SubprotocolRequest as OCPIRequest);
                    var httpResponseBuilder = OCPIResponseBuilder.ToHTTPResponseBuilder();

                    httpResponseBuilder.SubprotocolResponse = new OCPIResponse(OCPIResponseBuilder.Request,
                                                                               OCPIResponseBuilder.StatusCode ?? 3000,
                                                                               OCPIResponseBuilder.StatusMessage,
                                                                               OCPIResponseBuilder.AdditionalInformation,
                                                                               OCPIResponseBuilder.Timestamp ?? DateTime.UtcNow,
                                                                               httpResponseBuilder.AsImmutable);

                    return(httpResponseBuilder);
                }
                catch (Exception e)
                {
                    return(new HTTPResponse.Builder(HTTPStatusCode.InternalServerError)
                    {
                        ContentType = HTTPContentType.JSON_UTF8,
                        Content = new OCPIResponse <JObject>(
                            JSONObject.Create(
                                new JProperty("description", e.Message),
                                new JProperty("stacktrace", e.StackTrace.Split(new String[] { Environment.NewLine }, StringSplitOptions.None).ToArray()),
                                new JProperty("source", e.TargetSite.Module.Name),
                                new JProperty("type", e.TargetSite.ReflectedType.Name)
                                ),
                            2000,
                            e.Message,
                            null,
                            DateTime.UtcNow,
                            null,
                            (httpRequest.SubprotocolRequest as OCPIRequest)?.RequestId,
                            (httpRequest.SubprotocolRequest as OCPIRequest)?.CorrelationId
                            ).ToJSON(json => json).ToUTF8Bytes(),
                        Connection = "close"
                    });
                }
            },
                              AllowReplacement);
        }
コード例 #19
0
ファイル: CommonInterface.cs プロジェクト: vebin/WeiboSdk
 public CommonInterface(Client client)
     : base(client) {
     api = new CommonAPI(client);
 }
コード例 #20
0
        public static void SaveCurrentPath(ImageComboBoxEdit cmbPath, string sKey)
        {
            ImageComboBoxItem imageComboBoxItem = cmbPath.SelectedItem as ImageComboBoxItem;

            if (imageComboBoxItem != null)
            {
                string   text        = imageComboBoxItem.Value.ToString();
                string   description = imageComboBoxItem.Description;
                string   sPath       = text;
                IconType imageIndex  = (IconType)imageComboBoxItem.ImageIndex;
                if (imageIndex <= IconType.Coverage)
                {
                    switch (imageIndex)
                    {
                    case IconType.PGDB:
                        break;

                    case IconType.PGDBDataset:
                        goto IL_AB;

                    default:
                        if (imageIndex != IconType.Coverage)
                        {
                            goto IL_DB;
                        }
                        break;
                    }
                }
                else if (imageIndex != IconType.Cad)
                {
                    switch (imageIndex)
                    {
                    case IconType.E00:
                    case IconType.FGDB:
                    case IconType.SDE:
                        break;

                    case IconType.FGDBDataset:
                    case IconType.SDEDataset:
                        goto IL_AB;

                    case IconType.FGDBAnnotation:
                    case IconType.FGDBPoint:
                    case IconType.FGDBLine:
                    case IconType.FGDBPolygon:
                        goto IL_DB;

                    default:
                        goto IL_DB;
                    }
                }
                sPath = text.Substring(0, text.Length - description.Length - 1);
                goto IL_DB;
IL_AB:
                string text2 = text.Substring(0, text.Length - description.Length - 1);
                int length = text2.LastIndexOf('\\');
                sPath = text2.Substring(0, length);
IL_DB:
                CommonAPI.SavePathToRegistry(sPath, sKey);
            }
        }
コード例 #21
0
        public static DBConn getDynaConnection(DateTime dt_inserttime, bool b_create)
        {
            DBConn result;

            lock (DBConnPool._lockdatadb)
            {
                string str = "";
                if (DBUrl.SERVERMODE)
                {
                    try
                    {
                        DBConn   dBConn         = new DBConn();
                        string   cONNECT_STRING = DBUrl.CONNECT_STRING;
                        string[] array          = cONNECT_STRING.Split(new string[]
                        {
                            ","
                        }, StringSplitOptions.RemoveEmptyEntries);
                        dBConn.con = new MySqlConnection(string.Concat(new string[]
                        {
                            "Database=eco",
                            DBUrl.SERVERID,
                            ";Data Source=",
                            array[0],
                            ";Port=",
                            array[1],
                            ";User Id=",
                            array[2],
                            ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;"
                        }));
                        dBConn.con.Open();
                        dBConn.setInUse();
                        DebugCenter.GetInstance().clearStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                        result = dBConn;
                        return(result);
                    }
                    catch (Exception e)
                    {
                        DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                        DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e, false, "    "));
                        result = null;
                        return(result);
                    }
                }
                if (DBUrl.DB_CURRENT_TYPE.ToUpperInvariant().Equals("MYSQL"))
                {
                    try
                    {
                        DBConn dBConn2 = new DBConn();
                        dBConn2.con = new MySqlConnection(string.Concat(new object[]
                        {
                            "Database=",
                            DBUrl.DB_CURRENT_NAME,
                            ";Data Source=",
                            DBUrl.CURRENT_HOST_PATH,
                            ";Port=",
                            DBUrl.CURRENT_PORT,
                            ";User Id=",
                            DBUrl.CURRENT_USER_NAME,
                            ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;"
                        }));
                        dBConn2.con.Open();
                        dBConn2.setInUse();
                        DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_Success, false);
                        result = dBConn2;
                        return(result);
                    }
                    catch (Exception e2)
                    {
                        DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                        DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e2, false, "    "));
                        result = null;
                        return(result);
                    }
                }
                try
                {
                    string text = AppDomain.CurrentDomain.BaseDirectory + "datadb";
                    if (text[text.Length - 1] != Path.DirectorySeparatorChar)
                    {
                        text += Path.DirectorySeparatorChar;
                    }
                    if (!Directory.Exists(text))
                    {
                        Directory.CreateDirectory(text);
                    }
                    DateTime.Now.ToString("yyyyMMdd");
                    dt_inserttime.ToString("yyyyMMdd");
                    string text2 = text + "datadb_" + dt_inserttime.ToString("yyyyMMdd") + ".mdb";
                    if (!File.Exists(text2) && b_create)
                    {
                        string sourceFileName = text + "datadb.org";
                        File.Copy(sourceFileName, text2, true);
                    }
                    bool flag2 = false;
                    try
                    {
                        DBConn dBConn3 = new DBConn();
                        try
                        {
                            dBConn3.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text2 + ";Jet OLEDB:Database Password=root");
                            dBConn3.con.Open();
                            flag2 = true;
                        }
                        catch (Exception ex)
                        {
                            str = ex.Message + "\r\n" + ex.StackTrace;
                            int i = 0;
                            while (i < 4)
                            {
                                Thread.Sleep(10);
                                i++;
                                try
                                {
                                    dBConn3.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text2 + ";Jet OLEDB:Database Password=root");
                                    dBConn3.con.Open();
                                    flag2 = true;
                                    break;
                                }
                                catch (Exception ex2)
                                {
                                    str = ex2.Message + "\r\n" + ex2.StackTrace;
                                }
                            }
                        }
                        if (flag2)
                        {
                            dBConn3.setInUse();
                            dBConn3.DBSource_Type = 2;
                            try
                            {
                                StackTrace stackTrace = new StackTrace();
                                MethodBase method     = stackTrace.GetFrame(1).GetMethod();
                                DBCache.OpenDataDB(dBConn3.GetHashCode(), method.Name);
                                DBCache.PrintDataDB();
                            }
                            catch
                            {
                            }
                            result = dBConn3;
                        }
                        else
                        {
                            DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + str);
                            result = null;
                        }
                    }
                    catch (Exception ex3)
                    {
                        DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + ex3.Message + "\n" + ex3.StackTrace);
                        result = null;
                    }
                }
                catch (Exception ex4)
                {
                    DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + ex4.Message + "\n" + ex4.StackTrace);
                    result = null;
                }
            }
            return(result);
        }
コード例 #22
0
 internal static void SetupWebView <TApi>(this WebView webView, string editorName, bool readOnly, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi) where TApi : class
 {
     webView.SetupWebView(editorName, readOnly, false, out jsCtx, newJsApi, out jsApi, out jsCommonApi);
 }
コード例 #23
0
        //
        //获取地图状态信息
        //
        private void GetStatusXY(double mapX, double mapY)
        {
            try
            {
                if (this._barItemXY != null)
                {
                    ISpatialReference spatialReference = this._mapControl.SpatialReference;
                    if (spatialReference != null)
                    {
                        if (spatialReference is IProjectedCoordinateSystem)
                        {
                            IProjectedCoordinateSystem projectedCoordinateSystem = spatialReference as IProjectedCoordinateSystem;
                            IPoint point = new PointClass();
                            point.SpatialReference = spatialReference;
                            point.X = mapX;
                            point.Y = mapY;
                            point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                            double lon        = point.X;
                            double lat        = point.Y;
                            int    lon_degree = (int)Math.Floor(Convert.ToDecimal(lon));
                            int    lat_degree = (int)Math.Floor(Convert.ToDecimal(lat));
                            lon = (lon - lon_degree) * 60;
                            lat = (lat - lat_degree) * 60;
                            int lon_m = (int)Math.Floor(Convert.ToDecimal(lon));
                            int lat_m = (int)Math.Floor(Convert.ToDecimal(lat));
                            lon = (lon - lon_m) * 60;
                            lat = (lat - lat_m) * 60;
                            int    lon_s  = (int)Math.Floor(Convert.ToDecimal(lon));
                            int    lat_s  = (int)Math.Floor(Convert.ToDecimal(lat));
                            string strLon = "";
                            string strLat = "";
                            if (lon_degree > 0)
                            {
                                strLon = lon_degree + "° " + lon_m + "′ " + lon_s + "″ E";
                            }
                            else
                            {
                                strLon = lon_degree + "° " + lon_m + "′ " + lon_s + "″ E";
                            }
                            if (lat_degree > 0)
                            {
                                strLat = lat_degree + "° " + lat_m + "′ " + lat_s + "″ N";
                            }
                            else
                            {
                                strLat = lat_degree + "° " + lat_m + "′ " + lat_s + "″ N";
                            }
                            this._barItemXY.Caption = string.Format("坐标:{0},{1}", strLon, strLat);
                        }
                    }
                    else
                    {
                        this._barItemXY.Caption = string.Format("坐标:{0},{1}", mapX, mapY);
                    }
                }
                if (this._barItemRaster != null)
                {
                    this._barItemRaster.Visibility = BarItemVisibility.Never;
                    if (this._rasterLayer != null)
                    {
                        IRaster2 raster = this._rasterLayer.Raster as IRaster2;
                        IPoint   point  = new PointClass();
                        point.X = mapX;
                        point.Y = mapY;
                        point.SpatialReference = this._spatialReference;
                        ISpatialReference spatialReference = (raster as IGeoDataset).SpatialReference;
                        if (!EngineAPI.IsEqualSpatialReference(this._spatialReference, spatialReference))
                        {
                            point.Project(spatialReference);
                        }
                        int colum;
                        int row;
                        raster.MapToPixel(point.X, point.Y, out colum, out row);
                        if (colum >= 0 && colum <= this._rasterLayer.ColumnCount && row >= 0 && row <= this._rasterLayer.RowCount)
                        {
                            this._barItemRaster.Visibility = BarItemVisibility.Always;

                            double value = CommonAPI.ConvertToDouble(raster.GetPixelValue(0, colum, row));
                            this._barItemRaster.Caption = string.Format("行:{0}, 列:{1}, 像素值:{2}", row, colum, value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog(typeof(GFSApplication), ex);
            }
        }
コード例 #24
0
 internal static void SetupWebView <TApi>(this WebView webView, string editorName, bool readOnly, bool oldApi, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi)
 {
     webView.SetupWebView(out jsCtx, newJsApi, out jsApi, out jsCommonApi);
     webView.LoadResource(new ResourceUrl(typeof(WebViewExtensions).Assembly, new string[]
     {
         "WebViews",
         "Common",
         string.Concat(new string[]
         {
             "FormIoWebView",
             oldApi ? "-old" : "",
             ".html?render=",
             editorName,
             "&readOnly=",
             readOnly ? "true" : "false"
         })
     }));
 }
コード例 #25
0
        public void workQueue_DBWork(object sender, WorkQueue <string> .EnqueueEventArgs e)
        {
            try
            {
                if (!DBWorkThread.STOP_THREAD)
                {
                    string text = "";
                    if (TaskStatus.GetDBStatus() == -1)
                    {
                        try
                        {
                            this.con.Close();
                            this.con.Dispose();
                            this.con = null;
                        }
                        catch
                        {
                        }
                    }
                    if (this.con == null)
                    {
                        if (DBUrl.SERVERMODE)
                        {
                            string   cONNECT_STRING = DBUrl.CONNECT_STRING;
                            string[] array          = cONNECT_STRING.Split(new string[]
                            {
                                ","
                            }, StringSplitOptions.RemoveEmptyEntries);
                            this.con = new MySqlConnection(string.Concat(new string[]
                            {
                                "Database=eco",
                                DBUrl.SERVERID,
                                ";Data Source=",
                                array[0],
                                ";Port=",
                                array[1],
                                ";User Id=",
                                array[2],
                                ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=50;Default Command Timeout=0;charset=utf8;"
                            }));
                            this.con.Open();
                        }
                        else
                        {
                            if (DBWorkThread.STOP_THREAD)
                            {
                                return;
                            }
                            switch (this.DBTYPE)
                            {
                            case 0:
                                break;

                            case 1:
                                try
                                {
                                    this.con = new MySqlConnection(string.Concat(new object[]
                                    {
                                        "Database=",
                                        DBUrl.DB_CURRENT_NAME,
                                        ";Data Source=",
                                        DBUrl.CURRENT_HOST_PATH,
                                        ";Port=",
                                        DBUrl.CURRENT_PORT,
                                        ";User Id=",
                                        DBUrl.CURRENT_USER_NAME,
                                        ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;"
                                    }));
                                    this.con.Open();
                                    DebugCenter.GetInstance().clearStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                                    goto IL_2A6;
                                }
                                catch (Exception e2)
                                {
                                    DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                                    DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e2, false, "    "));
                                    goto IL_2A6;
                                }
                                break;

                            default:
                                goto IL_2A6;
                            }
                            try
                            {
                                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBUrl.CURRENT_HOST_PATH + ";Jet OLEDB:Database Password="******"Waiting DBConnection : " + num);
                                    num++;
                                }
                                DBConn dynaConnection = DBConnPool.getDynaConnection();
                                if (dynaConnection != null)
                                {
                                    this.con = dynaConnection.con;
                                }
                                else
                                {
                                    this.con = null;
                                }
                            }
                            catch (Exception ex)
                            {
                                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                            }
                        }
                    }
                    try
                    {
IL_2A6:
                        if (this.con.State != ConnectionState.Open)
                        {
                            try
                            {
                                this.con.Close();
                                this.con.Open();
                            }
                            catch (Exception e3)
                            {
                                this.con = null;
                                DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true);
                                DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e3, false, "    "));
                            }
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        if (this.cmd != null)
                        {
                            this.cmd.Dispose();
                        }
                    }
                    catch (Exception ex2)
                    {
                        DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex2.Message + "\n" + ex2.StackTrace);
                    }
                    try
                    {
                        string item = e.Item;
                        if (item.StartsWith("PDEND"))
                        {
                            InSnergyGateway.Need_Calculate_PUE = true;
                            DBWorkThread.NEEDLOG = true;
                        }
                        else
                        {
                            if (item.IndexOf("END") > -1)
                            {
                                DBCacheStatus.LastInsertTime = DateTime.Now;
                                DBWorkThread.NEEDLOG         = true;
                            }
                            else
                            {
                                this.cmd = this.con.CreateCommand();
                                int num2 = this.NeedU2I(item);
                                if (this.DBTYPE == 1 || DBUrl.SERVERMODE)
                                {
                                    string commandText = item.Replace("#", "'");
                                    this.cmd.CommandText = commandText;
                                }
                                else
                                {
                                    this.cmd.CommandText = item;
                                }
                                text = this.cmd.CommandText;
                                if (!DBWorkThread.STOP_THREAD)
                                {
                                    int num3 = this.cmd.ExecuteNonQuery();
                                    if (num3 < 1 && num2 > 0)
                                    {
                                        if (this.DBTYPE == 1 || DBUrl.SERVERMODE)
                                        {
                                            string text2 = this.ChgU2I(item, num2);
                                            text2 = text2.Replace("#", "'");
                                            this.cmd.CommandText = text2;
                                        }
                                        else
                                        {
                                            this.cmd.CommandText = this.ChgU2I(item, num2);
                                        }
                                        text = this.cmd.CommandText;
                                        if (DBWorkThread.STOP_THREAD)
                                        {
                                            return;
                                        }
                                        this.cmd.ExecuteNonQuery();
                                    }
                                    this.cmd.Dispose();
                                    if (TaskStatus.GetDBStatus() == -1)
                                    {
                                        try
                                        {
                                            this.con.Close();
                                        }
                                        catch
                                        {
                                        }
                                        try
                                        {
                                            this.con.Dispose();
                                        }
                                        catch
                                        {
                                        }
                                        this.con = null;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex3)
                    {
                        if (ex3.GetType().FullName.Equals("MySql.Data.MySqlClient.MySqlException"))
                        {
                            string tableName = DBUtil.GetTableName(text);
                            if (tableName != null && tableName.Length > 0)
                            {
                                DBUtil.SetMySQLInfo(tableName);
                                DebugCenter.GetInstance().appendToFile("MySQL database is marked as crashed, EcoSensor Monitor Service will be shutdown ");
                                DBUtil.StopService();
                            }
                        }
                        if (ex3.Message.ToLower().IndexOf("fatal error encountered during command execution") < 0)
                        {
                            if (text.IndexOf("rack_effect") > 0)
                            {
                                try
                                {
                                    DBTools.Write_DBERROR_Log();
                                    goto IL_56F;
                                }
                                catch
                                {
                                    goto IL_56F;
                                }
                            }
                            if (DBWorkThread.NEEDLOG)
                            {
                                try
                                {
                                    DBTools.Write_DBERROR_Log();
                                }
                                catch
                                {
                                }
                                DBWorkThread.NEEDLOG = false;
                            }
IL_56F:
                            DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex3.Message + "\n" + ex3.StackTrace);
                        }
                        try
                        {
                            this.cmd.Dispose();
                            this.con.Close();
                        }
                        catch (Exception)
                        {
                        }
                        this.con = null;
                    }
                }
            }
            finally
            {
                try
                {
                    if (this.con != null)
                    {
                        this.con.Close();
                    }
                    this.con = null;
                }
                catch
                {
                }
            }
        }
コード例 #26
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     if (Button == 1)
     {
         List <ILayer> layers = EngineAPI.GetLayers(this.m_hookHelper.FocusMap, "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}", null);
         if (layers.Count == 0)
         {
             IdentifyManager.instance.FrmIdentify.Close();
             IdentifyManager.instance.FrmIdentify      = null;
             EnviVars.instance.MapControl.CurrentTool  = null;
             EnviVars.instance.MapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
         }
         else
         {
             foreach (ILayer current in layers)
             {
                 IIdentify identify = current as IIdentify;
                 IPoint    point    = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                 IArray    array    = identify.Identify(point);
                 if (array != null && array.Count != 0)
                 {
                     IdentifyManager.instance.FrmIdentify.treeList1.ClearNodes();
                     IIdentifyObj identifyObj = array.get_Element(0) as IIdentifyObj;
                     identifyObj.Flash(this.m_hookHelper.ActiveView.ScreenDisplay);
                     TreeListNode treeListNode = IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                     {
                         identifyObj.Layer.Name
                     }, 0, identifyObj);
                     DataColumn column    = new DataColumn("字段", typeof(string));
                     DataColumn column2   = new DataColumn("值", typeof(string));
                     DataTable  dataTable = new DataTable();
                     dataTable.Columns.Add(column);
                     dataTable.Columns.Add(column2);
                     if (current is IFeatureLayer)
                     {
                         IFeature     feature       = (identifyObj as IRowIdentifyObject).Row as IFeature;
                         TreeListNode treeListNode2 = IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                         {
                             feature.OID.ToString()
                         }, treeListNode);
                         int num = feature.Fields.FindField((current as IFeatureLayer).FeatureClass.ShapeFieldName);
                         for (int i = 0; i < feature.Fields.FieldCount; i++)
                         {
                             if (num != i)
                             {
                                 DataRow dataRow = dataTable.NewRow();
                                 dataRow["字段"] = feature.Fields.get_Field(i).AliasName;
                                 dataRow["值"]  = feature.get_Value(i).ToString();
                                 dataTable.Rows.Add(dataRow);
                             }
                         }
                         treeListNode2.Tag = dataTable;
                     }
                     else if (current is IRasterLayer)
                     {
                         IRasterLayer rasterLayer = current as IRasterLayer;
                         IRaster2     raster      = rasterLayer.Raster as IRaster2;
                         int          num2        = raster.ToPixelRow(point.Y);
                         int          num3        = raster.ToPixelColumn(point.X);
                         double       num4        = CommonAPI.ConvertToDouble(raster.GetPixelValue(0, num3, num2));
                         this.AddRow(dataTable, "像素值", num4);
                         this.AddRow(dataTable, "行号", num2);
                         this.AddRow(dataTable, "列号", num3);
                         IRasterIdentifyObj rasterIdentifyObj = array.get_Element(0) as IRasterIdentifyObj;
                         if (rasterLayer.BandCount != 1)
                         {
                             Regex           regex           = new Regex("\\d{2,3}");
                             MatchCollection matchCollection = regex.Matches(rasterIdentifyObj.MapTip);
                             if (matchCollection.Count == 3)
                             {
                                 this.AddRow(dataTable, "R", matchCollection[0].Value);
                                 this.AddRow(dataTable, "G", matchCollection[1].Value);
                                 this.AddRow(dataTable, "B", matchCollection[2].Value);
                             }
                         }
                         IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                         {
                             rasterIdentifyObj.Name
                         }, treeListNode, dataTable);
                     }
                     IdentifyManager.instance.FrmIdentify.UpdateStatusText(string.Format("X:{0:0.000 },Y:{1:0.000}", point.X, point.Y));
                     IdentifyManager.instance.FrmIdentify.treeList1.ExpandAll();
                     if (treeListNode.Nodes.Count > 0)
                     {
                         IdentifyManager.instance.FrmIdentify.treeList1.FocusedNode = treeListNode.Nodes[0];
                     }
                     IdentifyManager.instance.FrmIdentify.Show();
                     break;
                 }
                 IdentifyManager.instance.FrmIdentify.Close();
                 IdentifyManager.instance.FrmIdentify = null;
             }
         }
     }
 }