Exemple #1
0
        //发送消息
        public static bool SendMessage(string message, string uid = "")
        {
            string      app_key       = System.Configuration.ConfigurationManager.AppSettings["APP_KEY"];
            string      master_secret = System.Configuration.ConfigurationManager.AppSettings["MASTER_SECRET"];
            JPushClient client        = new JPushClient(app_key, master_secret);
            DateTime    dt1           = DateTime.Now;

            PushPayload payload = PushObject_All_Message(message, uid);

            try
            {
                var result = client.SendPush(payload);

                int a = 10;
            }
            catch (Exception ex)
            {
                LibLog.WriteLog(ex);
            }
            return(true);
        }
Exemple #2
0
        public void ImportToDataSet(string filePath, DataSet dataSet, Action <System.Data.DataTable> actionTable, Func <DataRow, Dictionary <string, object>, bool> actionRow, bool dbField = false)
        {
            try
            {
                string        connStr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='{0}'; Extended Properties='Excel 8.0;HDR=Yes;IMEX=2'", filePath);
                List <string> sqlList = new List <string>();
                foreach (System.Data.DataTable table in dataSet.Tables)
                {
                    string tableName = string.Empty;
                    if (dbField)
                    {
                        tableName = table.TableName;
                    }
                    else
                    {
                        if (table.ExtendedProperties.ContainsKey(TableProperty.DisplayText))
                        {
                            tableName = LibSysUtils.ToString(table.ExtendedProperties[TableProperty.DisplayText]);
                        }
                        else
                        {
                            tableName = table.TableName;
                        }
                    }
                    sqlList.Add(string.Format("select * from [{0}$]", tableName));
                }
                dataSet.EnforceConstraints = false;
                using (OleDbConnection conn = new OleDbConnection(connStr))
                {
                    conn.Open();
                    try
                    {
                        int i = 0;
                        foreach (string sql in sqlList)
                        {
                            System.Data.DataTable           curTable = dataSet.Tables[i];
                            Dictionary <string, DataColumn> colMap   = null;
                            if (!dbField)
                            {
                                colMap = new Dictionary <string, DataColumn>();
                                foreach (DataColumn col in curTable.Columns)
                                {
                                    try
                                    {
                                        colMap.Add(col.Caption, col);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw ex;
                                    }
                                }
                            }
                            curTable.BeginLoadData();
                            try
                            {
                                using (OleDbCommand command = new OleDbCommand(sql, conn))
                                {
                                    using (IDataReader reader = command.ExecuteReader())
                                    {
                                        while (reader.Read())
                                        {
                                            bool canAdd = true;
                                            Dictionary <string, object> otherValueList = null;
                                            DataRow newRow = curTable.NewRow();
                                            newRow.BeginEdit();
                                            try
                                            {
                                                bool allNull = true;
                                                for (int l = 0; l < reader.FieldCount; l++)
                                                {
                                                    string colName = reader.GetName(l).Trim();
                                                    if (!Convert.IsDBNull(reader[l]))
                                                    {
                                                        if (allNull)
                                                        {
                                                            allNull = false;
                                                        }
                                                        string realName = string.Empty;
                                                        if (dbField)
                                                        {
                                                            if (curTable.Columns.Contains(colName))
                                                            {
                                                                realName = colName;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (colMap.ContainsKey(colName))
                                                            {
                                                                realName = colMap[colName].ColumnName;
                                                            }
                                                        }
                                                        if (!string.IsNullOrEmpty(realName))
                                                        {
                                                            LibControlType controlType = (LibControlType)colMap[colName].ExtendedProperties[FieldProperty.ControlType];
                                                            if (controlType == LibControlType.DateTime || controlType == LibControlType.Date)
                                                            {
                                                                DateTime curTime;
                                                                DateTime.TryParse(LibSysUtils.ToString(reader[l]), out curTime);
                                                                if (controlType == LibControlType.Date)
                                                                {
                                                                    newRow[realName] = LibDateUtils.DateTimeToLibDate(curTime);
                                                                }
                                                                else if (controlType == LibControlType.DateTime)
                                                                {
                                                                    newRow[realName] = LibDateUtils.DateTimeToLibDateTime(curTime);
                                                                }
                                                            }
                                                            else if (controlType == LibControlType.HourMinute)
                                                            {
                                                                string hourtime = LibSysUtils.ToString(reader[l]);
                                                                hourtime         = hourtime.Replace(":", "");
                                                                newRow[realName] = LibSysUtils.ToInt32(hourtime);
                                                            }
                                                            else if (controlType == LibControlType.Text || controlType == LibControlType.NText)
                                                            {
                                                                newRow[realName] = LibSysUtils.ToString(reader[l]).Trim();
                                                            }
                                                            else
                                                            {
                                                                newRow[realName] = reader[l];
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (otherValueList == null)
                                                            {
                                                                otherValueList = new Dictionary <string, object>();
                                                            }
                                                            if (!otherValueList.ContainsKey(colName))
                                                            {
                                                                otherValueList.Add(colName, reader[l]);
                                                            }
                                                        }
                                                    }
                                                }
                                                canAdd = !allNull; //全为null的行是空行不需要导入
                                                if (canAdd)
                                                {
                                                    canAdd = actionRow(newRow, otherValueList);
                                                }
                                            }
                                            finally
                                            {
                                                newRow.EndEdit();
                                            }
                                            if (canAdd)
                                            {
                                                curTable.Rows.Add(newRow);
                                            }
                                        }
                                    }
                                    actionTable(curTable);
                                }
                            }
                            finally
                            {
                                curTable.EndLoadData();
                            }
                            i++;
                        }
                    }
                    catch (Exception ex)
                    {
                        Exception ex1 = ex;
                    }
                    finally
                    {
                        conn.Close();
                        dataSet.EnforceConstraints = true;
                    }
                }
            }
            catch (Exception ex)
            {
                if (dataSet.HasErrors)
                {
                    string errorData = string.Empty;
                    foreach (DataTable dt in dataSet.Tables)
                    {
                        foreach (DataRow dr in dt.GetErrors())
                        {
                            errorData += string.Format(" {0}", dr.RowError);
                        }
                    }
                    Exception dsEx = new Exception(errorData);
                    LibLog.WriteLog(dsEx);
                }

                LibLog.WriteLog(ex);
                throw;
            }
        }
Exemple #3
0
        public void ProcessRequest(HttpContext context)
        {
            string action = context.Request["action"].ToLower();
            object ret    = null;

            try
            {
                switch (action)
                {
                case "checkfieldvalue":
                    ret = checkFieldValue(context);
                    break;

                case "fuzzysearchfield":
                    ret = fuzzySearchField(context);
                    break;

                case "savemenusetting":
                    ret = SaveMenuSetting(context);
                    break;

                case "loadmenusetting":
                    ret = LoadMenuSetting(context);
                    break;

                case "getrptfields":
                    ret = GetRptFields(context);
                    break;

                case "getjspath":
                    ret = GetJsPath(context);
                    break;

                case "savebilllistingscheme":
                    ret = SaveBillListingScheme(context);
                    break;

                case "print":
                    ret = Print(context);
                    break;

                case "selectqueryfield":
                    ret = SelectQueryField(context);
                    break;

                case "selectfuncfield":
                    ret = SelectFuncField(context);
                    break;

                case "uploadfile":
                    ret = UpLoadFile(context);
                    break;

                case "batchexportalldata":
                    ret = BatchExportAllData(context);
                    break;

                case "batchexport":
                    ret = BatchExportData(context);
                    break;

                case "batchimport":
                    ret = BatchImportData(context);
                    break;

                case "getlist":
                    ret = getList(context);
                    break;

                case "batchmethod":
                    ret = BatchMethod(context);
                    break;

                case "method":
                    ret = processRequsetExecuteMethod(context);
                    break;

                case "login":
                    ret = Login(context);
                    break;

                case "weixin":
                    ret = GetDiary(context);
                    break;

                case "update":
                    SystemManager info = new SystemManager();
                    info.SystemUpgrade1();
                    break;

                default:
                    throw new Exception("没有对应的方法");
                    break;
                }
            }
            catch (Exception ex)
            {
                LibLog.WriteLog(ex);
                ret = new ExecuteBcfMethodResult(ex.Message);
            }

            string json = JsonConvert.SerializeObject(ret);

            context.Response.Write(json);
            context.Response.End();
        }