示例#1
0
 public override void ReadFields(DataBaseIO input)
 {
     L.I("Get New Config...");
     L.I(input.Stringify());
     base.ReadFields(input);
     PropContent = input.GetString("PropContent");
     PropName    = input.GetString("PropName");
 }
示例#2
0
 public override void WriteObject(DataBaseIO output, bool all)
 {
     base.WriteObject(output, all);
     output.Put("ReportTeacherID", TeacherID);
     output.Put("ReportBusID", BusID);
     output.Put("ReportType", (int)ReportType);
     output.Put("DetailedInformation", OtherData);
 }
示例#3
0
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     TeacherID  = input.GetString("ReportTeacherID");
     BusID      = input.GetString("ReportBusID");
     ReportType = (BusReportTypeE)input.GetInt("ReportType");
     OtherData  = input.GetString("DetailedInformation");
 }
示例#4
0
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     Title     = input.GetString("Title");
     Content   = input.GetString("Content");
     Sender    = input.GetString("Sender");
     Receivers = input.GetString("Receiver").Split(';').ToList();
     Type      = (WeChatNotificationType)input.GetInt("type");
 }
示例#5
0
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     BusName   = input.GetString("BusName");
     TeacherID = input.GetString("TeacherObjectID");
     LSChecked = input.GetBool("LSChecked");
     CSChecked = input.GetBool("CSChecked");
     AHChecked = input.GetBool("AHChecked");
 }
 public virtual void WriteObject(DataBaseIO output, bool all)
 {
     output.Put("objectId", ObjectId);
     if (all)
     {
         output.Put("createdAt", CreatedAt);
         output.Put("updatedAt", UpdatedAt);
     }
 }
示例#7
0
 public override void WriteObject(DataBaseIO output, bool all)
 {
     base.WriteObject(output, all);
     output.Put("BusName", BusName);
     output.Put("TeacherObjectID", TeacherID);
     output.Put("CSChecked", CSChecked);
     output.Put("LSChecked", LSChecked);
     output.Put("AHChecked", AHChecked);
 }
示例#8
0
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     UserID              = input.GetString("UserID");
     SolverID            = input.GetString("SolverID");
     RequestTypes        = (UserChangeRequestTypes)input.GetInt("RequestType");
     DetailTexts         = input.GetString("DetailTexts");
     NewContent          = input.GetString("NewContent");
     ProcessResultReason = (UCRRefusedReasons)input.GetInt("ResultReason");
     Status              = (UCRProcessStatus)input.GetInt("Status");
 }
示例#9
0
        //写字段信息
        public override void WriteObject(DataBaseIO output, bool all)
        {
            string recv = GetStringRecivers();

            base.WriteObject(output, all);
            output.Put("Title", Title);
            output.Put("Content", Content);
            output.Put("Type", (int)Type);
            output.Put("Sender", Sender);
            output.Put("Receiver", recv);
        }
        private static int CommandCreate(string TableName, DataBaseIO output)
        {
            string sqlCommand_Create =
                $"INSERT INTO {TableName} " +
                $"({string.Join(",", output.Data.Keys)}, createdAt, updatedAt)" +
                $" VALUES " +
                $"('{string.Join("','", (from val in output.Data.Values select (PublicTools.EncodeString(val))).ToArray())}', '{DateTime.Now}', '{DateTime.Now}')";
            SqlCommand command_Create = new SqlCommand(sqlCommand_Create, sqlConnection);

            return(command_Create.ExecuteNonQuery());
        }
        private static int CommandUpdate(string TableName, string ObjectID, DataBaseIO output)
        {
            string sqlCommand_Update =
                $"UPDATE {TableName} " +
                $"SET {string.Join(",", (from q in output.Data select $"{q.Key} = '{PublicTools.EncodeString(q.Value)}' ").ToArray())}, updatedAt = '{DateTime.Now}' " +
                $"WHERE objectId = '{ObjectID}'";

            SqlCommand command_Update = new SqlCommand(sqlCommand_Update, sqlConnection);

            return(command_Update.ExecuteNonQuery());
        }
示例#12
0
 public override void WriteObject(DataBaseIO output, bool all)
 {
     base.WriteObject(output, all);
     output.Put("UserID", UserID);
     output.Put("SolverID", SolverID);
     output.Put("RequestType", (int)RequestTypes);
     output.Put("DetailTexts", DetailTexts);
     output.Put("NewContent", NewContent);
     output.Put("Status", (int)Status);
     output.Put("ResultReason", (int)ProcessResultReason);
 }
 public override void WriteObject(DataBaseIO output, bool all)
 {
     base.WriteObject(output, all);
     output.Put("StuName", StudentName);
     output.Put("BusID", BusID);
     output.Put("Sex", Sex);
     output.Put("ClassID", ClassID);
     //output.Put("ParentsIDs", ParentsID);
     output.Put("CHChecked", AHChecked);
     output.Put("CSChecked", CSChecked);
     output.Put("LSChecked", LSChecked);
 }
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     StudentName = input.GetString("StuName");
     BusID       = input.GetString("BusID");
     Sex         = input.GetString("Sex");
     ClassID     = input.GetString("ClassID");
     //ParentsID = input.getString("ParentsIDs");
     CSChecked = input.GetBool("CSChecked");
     LSChecked = input.GetBool("LSChecked");
     AHChecked = input.GetBool("CHChecked");
 }
示例#15
0
 public override void ReadFields(DataBaseIO input)
 {
     base.ReadFields(input);
     StudentName = input.GetString("StuName");
     BusID       = input.GetString("BusID");
     Sex         = input.GetString("Sex");
     ClassID     = input.GetString("ClassID");
     //ParentsID = input.getString("ParentsIDs");
     CSChecked    = input.GetBool("CSChecked");
     LSChecked    = input.GetBool("LSChecked");
     TakingBus    = input.GetBool("TakingBus");
     AHChecked    = input.GetBool("CHChecked");
     WeekType     = (StudentBigWeekMode)input.GetInt("WeekType");
     DirectGoHome = (DirectGoHomeMode)input.GetInt("DirectGoHome");
 }
示例#16
0
 public override void WriteObject(DataBaseIO output, bool all)
 {
     base.WriteObject(output, all);
     output.Put("StuName", StudentName);
     output.Put("BusID", BusID);
     output.Put("Sex", Sex);
     output.Put("ClassID", ClassID);
     //output.Put("ParentsIDs", ParentsID);
     output.Put("CHChecked", AHChecked);
     output.Put("CSChecked", CSChecked);
     output.Put("LSChecked", LSChecked);
     output.Put("TakingBus", TakingBus);
     output.Put("WeekType", (int)WeekType);
     output.Put("DirectGoHome", (int)DirectGoHome);
 }
示例#17
0
        public static DBQueryStatus CreateData <T>(T data, out T dataOut) where T : DataTableObject <T>, new()
        {
            DataBaseIO output = new DataBaseIO();

            data.ObjectId = Cryptography.RandomString(10, false);
            data.WriteObject(output, false);
            DBQueryStatus rst = _DBRequestInternal(data.Table, DBVerbs.Create, null, output, out DataBaseIO[] inputs);

            if (rst == DBQueryStatus.INTERNAL_ERROR)
            {
                dataOut = null;
                return(rst);
            }
            T t = new T();

            t.ReadFields(inputs[0]);
            dataOut = t;
            return(rst);
        }
示例#18
0
        public static DBQueryStatus UpdateData <T>(ref T item, DBQuery query) where T : DataTableObject <T>, new()
        {
            if (query == null)
            {
                query = new DBQuery().WhereIDIs(item.ObjectId);
            }
            query.Limit(1);
            DataBaseIO output = new DataBaseIO();

            item.WriteObject(output, false);
            var _result = _DBRequestInternal(item.Table, DBVerbs.Update, query, output, out DataBaseIO[] inputs);

            if (_result != DBQueryStatus.ONE_RESULT)
            {
                L.E("UpdateData Process Failed!");
                return(DBQueryStatus.INTERNAL_ERROR);
            }
            item = new T();
            item.ReadFields(inputs[0]);
            return(_result);
        }
示例#19
0
        public override void WriteObject(DataBaseIO output, bool all)
        {
            base.WriteObject(output, all);
            output.Put("Username", UserName);
            output.Put("Password", Password);
            output.Put("Sex", Sex);

            //output.Put("isAdmin", UserGroup.IsAdmin);  DISABLED DUE TO SECURTY ISSUE....
            output.Put("isClassTeacher", UserGroup.IsClassTeacher);
            output.Put("isBusTeacher", UserGroup.IsBusManager);
            output.Put("isParent", UserGroup.IsParent);

            output.Put("RealName", RealName);
            output.Put("HeadImage", HeadImagePath);
            output.Put("PhoneNumber", PhoneNumber);

            output.Put("ClassIDs", ClassList);
            output.Put("ChildIDs", ChildList);

            output.Put("longitude", CurrentPoint.X);
            output.Put("latitude", CurrentPoint.Y);
            output.Put("precision", Precision);
        }
示例#20
0
        private static DBQueryStatus _DBRequestInternal(string Table, DBVerbs operation, DBQuery query, DataBaseIO output, out DataBaseIO[] results)
        {
            try
            {
                if ((operation == DBVerbs.QueryMulti || operation == DBVerbs.QuerySingle || operation == DBVerbs.Update || operation == DBVerbs.Delete) && query == null)
                {
                    throw new ArgumentNullException("When using Query Single/Multi and Change, Delete. Arg: query cannot be null");
                }
                if ((operation == DBVerbs.Create || operation == DBVerbs.Update) && output == null)
                {
                    throw new ArgumentNullException("When using Query Create and Change. Arg: output cannot be null");
                }
                DBInternal internalQuery = new DBInternal {
                    Verb = operation, TableName = Table
                };
                switch (operation)
                {
                case DBVerbs.Create:
                    internalQuery.DBObjects = output.MoveToArray();
                    break;

                case DBVerbs.QuerySingle:
                case DBVerbs.QueryMulti:
                    internalQuery.Query = query;
                    break;

                case DBVerbs.Update:
                    internalQuery.DBObjects = output.MoveToArray();
                    internalQuery.Query     = query;
                    break;

                case DBVerbs.Delete:
                    internalQuery.Query = query;
                    break;
                }

                string internalQueryString = internalQuery.ToParsedString();

                string _MessageId = MessageId;
                if (!DatabaseSocketsClient.SendData(internalQueryString, _MessageId, out string rcvdData))
                {
                    results = null;
                    throw new DataBaseException("Database is not connected currently...");
                }

                if (!rcvdData.ToParsedObject(out DBInternal reply))
                {
                    throw new DataBaseException("DBInternalReply is null");
                }

                // THERE ARE SOME SPECIAL REPLY CODE....
                switch (reply.ResultCode)
                {
                case DBQueryStatus.INJECTION_DETECTED:
                    throw new DataBaseException("INJECTION DETECTED.", reply.Exception);

                case DBQueryStatus.INTERNAL_ERROR:
                    throw new DataBaseException("Database Server Internal Error", reply.Exception);
                }

                switch (operation)
                {
                case DBVerbs.QueryMulti:
                    results = reply.DBObjects;
                    break;

                case DBVerbs.QuerySingle:
                case DBVerbs.Create:
                case DBVerbs.Update:
                    var singleResult = reply.DBObjects;
                    if (singleResult.Length > 1)
                    {
                        throw new DataBaseException("QuerySingle, Create, Change require only one Return result...");
                    }
                    if (operation == DBVerbs.QuerySingle)
                    {
                        //Allow No results....
                        results =
                            singleResult.Length == 0
                                ? new DataBaseIO[0]
                                : singleResult;
                    }
                    else
                    {
                        //DisAllow Empty Results....
                        results =
                            singleResult.Length == 0
                                ? throw new DataBaseException("Create Update functions expect one result...")
                                : singleResult;
                    }
                    break;

                case DBVerbs.Delete:
                    results = null;
                    break;

                default: throw new DataBaseException("Database Operation " + operation + " is not Supported!");
                }
                return(reply.ResultCode);
            }
            catch (DataBaseException ex)
            {
                results = null;
                LW.E(ex);
                return(DBQueryStatus.INTERNAL_ERROR);
            }
        }
示例#21
0
 public static string GetString(this DataBaseIO io, string Key) => io.Get <string>(Key) ?? string.Empty;
 public static DateTime GetDateTime(this DataBaseIO io, string Key) => io.GetT <DateTime>(Key);
 public static int GetInt(this DataBaseIO io, string Key) => io.GetT <int>(Key);
 public static bool GetBool(this DataBaseIO io, string Key) => io.GetT <bool>(Key);
        public static List <string> GetList(this DataBaseIO io, string Key)
        {
            string _listString = GetString(io, Key);

            return(string.IsNullOrWhiteSpace(_listString) ? new List <string>() : _listString.Split(',').ToList());
        }
 public static string GetString(this DataBaseIO io, string Key) => io.GetT <string>(Key);
示例#27
0
        private static DBQueryStatus _DBRequestInternal(string Table, DBVerbs operation, DBQuery query, DataBaseIO output, out DataBaseIO[] results)
        {
            try
            {
                //We gonna throw some exceptions!
                if ((operation == DBVerbs.QueryMulti || operation == DBVerbs.QuerySingle || operation == DBVerbs.Update || operation == DBVerbs.Delete) && query == null)
                {
                    throw new ArgumentNullException("When using Query Single/Multi and Change, Delete. Arg: query cannot be null");
                }

                if ((operation == DBVerbs.Create || operation == DBVerbs.Update) && output == null)
                {
                    throw new ArgumentNullException("When using Query Create and Change. Arg: output cannot be null");
                }

                DataBaseSocketIO internalQuery = new DataBaseSocketIO {
                    Verb = operation, TableName = Table
                };
                switch (operation)
                {
                case DBVerbs.Create:
                    internalQuery.DBObjects = output.MoveToArray();
                    break;

                case DBVerbs.QuerySingle:
                case DBVerbs.QueryMulti:
                    internalQuery.Query = query;
                    break;

                case DBVerbs.Update:
                    internalQuery.DBObjects = output.MoveToArray();
                    internalQuery.Query     = query;
                    break;

                case DBVerbs.Delete:
                    internalQuery.Query = query;
                    break;
                }

                string internalQueryString = internalQuery.Stringify();

                string _MessageId = MessageId;
                if (!DatabaseSocketsClient.SendCommand(internalQueryString, _MessageId, out string rcvdData))
                {
                    results = null;
                    throw new DataBaseException("Database is not connected currently...");
                }

                if (!rcvdData.ToParsedObject(out DataBaseSocketIO reply))
                {
                    throw new DataBaseException("DBInternalReply is null");
                }

                //time to throw exceptions! (again)
                switch (reply.ResultCode)
                {
                case DBQueryStatus.INJECTION_DETECTED: throw new DataBaseException("INJECTION DETECTED.", reply.Exception);

                case DBQueryStatus.INTERNAL_ERROR: throw new DataBaseException("Database Server Internal Error", reply.Exception);
                }

                switch (operation)
                {
                case DBVerbs.QueryMulti:
                    results = reply.DBObjects ?? throw new DataBaseException("Query DBObjects should have non-null result.");
                    break;

                case DBVerbs.Create:
                case DBVerbs.Update:
                case DBVerbs.QuerySingle:
                    if (reply.DBObjects.Length != 1)
                    {
                        throw new DataBaseException("Create & Update & QuerySingle expect 1 result.");
                    }
                    results = reply.DBObjects;
                    break;

                case DBVerbs.Delete:
                    results = null;
                    break;

                //Who knows what the hell it is...
                default: throw new DataBaseException("Database Operation is not Supported!");
                }
                return(reply.ResultCode);
            }
            catch (Exception ex)
            {
                results = null;
                ex.LogException();
                return(DBQueryStatus.INTERNAL_ERROR);
            }
        }
示例#28
0
 public static List <string> GetList(this DataBaseIO io, string Key) => io.GetList(Key, ',');
 public virtual void ReadFields(DataBaseIO input)
 {
     ObjectId  = input.GetString("objectId");
     CreatedAt = input.GetDateTime("createdAt");
     UpdatedAt = input.GetDateTime("updatedAt");
 }