public override QueryMetadata Handle(GetQueryMetadataAppOperationOptions options, IAppOperationContext operationContext)
        {
            QueryMetadata metaData = new QueryMetadata();

            try {
                ConnectDB conn = new ConnectDB();
                Class_ManageSettingInstance v_s         = new Class_ManageSettingInstance();
                List <SettingIRPClass>      Las_NameCat = Class_ManageSettingInstance.GetSettingWebQuery("XWEB_QUERY");
                QueryMetaD            QDM     = v_s.GetQueryMetaData(Las_NameCat, options.QueryRef.Id, options.OtherArgs.UserId);
                List <ColumnMetadata> colMeta = new List <ColumnMetadata>();
                if (QDM != null)
                {
                    if (QDM.Columns != null)
                    {
                        foreach (ColumnMetaD mdf in QDM.Columns)
                        {
                            ColumnMetadata metaCol = new ColumnMetadata();
                            metaCol.Description = mdf.Description;
                            metaCol.Format      = mdf.Format;
                            metaCol.JsonOptions = "";
                            metaCol.Order       = mdf.Order;
                            metaCol.Position    = 0;
                            metaCol.Rank        = mdf.Rank;
                            metaCol.Show        = mdf.Show;
                            metaCol.Style       = new ColumnStyle();
                            metaCol.Title       = mdf.Title;
                            if (mdf.Type == typeof(int))
                            {
                                metaCol.Type = Contracts.CommonDataType.Integer;
                            }
                            else if (mdf.Type == typeof(double))
                            {
                                metaCol.Type = Contracts.CommonDataType.Double;
                            }
                            else if (mdf.Type == typeof(string))
                            {
                                metaCol.Type = Contracts.CommonDataType.String;
                            }
                            else if (mdf.Type == typeof(float))
                            {
                                metaCol.Type = Contracts.CommonDataType.Double;
                            }
                            else if (mdf.Type == typeof(bool))
                            {
                                metaCol.Type = Contracts.CommonDataType.Boolean;
                            }
                            else if (mdf.Type == typeof(DateTime))
                            {
                                metaCol.Type = Contracts.CommonDataType.DateTime;
                            }
                            else if (mdf.Type == typeof(byte))
                            {
                                metaCol.Type = Contracts.CommonDataType.Bytes;
                            }
                            metaCol.Width = mdf.Width;
                            colMeta.Add(metaCol);
                        }
                    }



                    //Описание параметров запроса (Имя поля - значение)  (НА ТЕКУЩИЙ МОМЕНТ НИЧЕГО НЕ ПЕРЕДАЮ)
                    //List<QueryParameter> Qparams = new List<QueryParameter>();
                    //QueryParameter Qpar = new QueryParameter();
                    //Qpar.Name = "";
                    //Qpar.Value = "";
                    //Qparams.Add(Qpar);



                    //Таблица стилей (НА ТЕКУЩИЙ МОМЕНТ НИЧЕГО НЕ ПЕРЕДАЮ)

                    /*
                     * QueryTableStyle QStyle = new QueryTableStyle();
                     * QStyle.BackColor = "";
                     * QStyle.FontName = "";
                     * QStyle.FontSize = 12;
                     * QStyle.FontStyle = "";
                     * QStyle.ForeColor = "";
                     */


                    metaData.Columns     = colMeta.ToArray();
                    metaData.Description = QDM.Description;
                    metaData.JsonOptions = "";
                    metaData.Name        = QDM.Name;
                    metaData.Parameters  = null;
                    metaData.QueryRef    = options.QueryRef;
                    metaData.TableStyle  = new QueryTableStyle();
                    metaData.Techno      = QDM.Techno;
                    metaData.Title       = QDM.Title;
                }
                Logger.Trace(this, options, operationContext);
            }
            catch (Exception ex) { Logger.Error(ex); }
            return(metaData);
        }
예제 #2
0
        public override QueryChangesResult Handle(SaveChangesAppOperationOptions options, IAppOperationContext operationContext)
        {
            QueryChangesResult result = new QueryChangesResult();

            try {
                Class_ManageSettingInstance       v_s     = new Class_ManageSettingInstance();
                List <QueryChangesetActionResult> L_chRes = new List <QueryChangesetActionResult>();
                QueryChangesetActionResult        chRes   = new QueryChangesetActionResult();
                result.QueryRef         = new QueryReference();
                result.QueryRef.Id      = options.Changeset.QueryRef.Id;
                result.QueryRef.Version = options.Changeset.QueryRef.Version;
                int user_id = options.OtherArgs.UserId;
                Dictionary <string, object> Params = options.OtherArgs.Values;
                int max_Val = ConnectDB.NullI;  int ID_Record = ConnectDB.NullI;
                foreach (KeyValuePair <string, object> p in Params)
                {
                    if (p.Key == "ID")
                    {
                        ID_Record = Convert.ToInt32(p.Value); break;
                    }
                }
                List <SettingIRPClass> Las_NameCat = Class_ManageSettingInstance.GetSettingWebQuery("XWEB_QUERY");
                QueryMetaD             MD          = v_s.GetQueryMetaData(Las_NameCat, options.Changeset.QueryRef.Id, options.OtherArgs.UserId);
                SettingIRPClass        settIRP     = Las_NameCat.Find(z => z.ID == options.Changeset.QueryRef.Id);
                if (settIRP.IS_SQL_REQUEST == false)
                {
                    List <BlockDataFind> obj_base = new List <BlockDataFind>();
                    foreach (QueryChangesetAction act in options.Changeset.Actions)
                    {
                        int D_I = ConnectDB.NullI;
                        if ((act.Type == ChangesetActionType.Update) && (ID_Record != ConnectDB.NullI))
                        {
                            obj_base = v_s.GetFieldFromFormFinder(MD, settIRP, true, Params);
                            D_I      = v_s.SaveToOrmDataEdit(MD, settIRP, obj_base, null, (int)ID_Record, user_id, out max_Val);
                            if (D_I != ConnectDB.NullI)
                            {
                                chRes.Success = true; chRes.Message = "Succesfully updated record";
                            }
                            else
                            {
                                chRes.Success = false; chRes.Message = "Error updated record";
                            }
                            chRes.Type         = ChangesetActionType.Update;
                            chRes.RecordRef    = new RecordReference();
                            chRes.RecordRef.Id = D_I;
                            L_chRes.Add(chRes);
                        }
                        else if (act.Type == ChangesetActionType.Create)
                        {
                            obj_base = v_s.GetFieldFromFormFinderCreate(MD, settIRP, true, Params);
                            D_I      = v_s.SaveToOrmDataEdit(MD, settIRP, obj_base, null, ConnectDB.NullI, user_id, out max_Val);
                            if (D_I != ConnectDB.NullI)
                            {
                                chRes.Success = true; chRes.Message = "Succesfully created new record";
                            }
                            else
                            {
                                chRes.Success = false; chRes.Message = "Error created new record";
                            }
                            chRes.Type         = ChangesetActionType.Create;
                            chRes.RecordRef    = new RecordReference();
                            chRes.RecordRef.Id = D_I;
                            L_chRes.Add(chRes);
                        }
                        else if ((act.Type == ChangesetActionType.Delete) && (ID_Record != ConnectDB.NullI))
                        {
                            if (ConnectDB.SetStatusArchive(ID_Record, MD.TableName))
                            {
                                chRes.Success      = true; chRes.Message = string.Format("Succesfully update status = 'Z' for ID = {0}, table_name={1}", ID_Record, MD.TableName);
                                chRes.Type         = ChangesetActionType.Create;
                                chRes.RecordRef    = new RecordReference();
                                chRes.RecordRef.Id = ID_Record;
                                L_chRes.Add(chRes);
                            }
                            else
                            {
                                chRes.Success      = false; chRes.Message = string.Format("Error updated status = 'Z' for ID = {0}, table_name={1}", ID_Record, MD.TableName);
                                chRes.Type         = ChangesetActionType.Delete;
                                chRes.RecordRef    = new RecordReference();
                                chRes.RecordRef.Id = ID_Record;
                                L_chRes.Add(chRes);
                            }
                        }
                    }
                }
                else
                {
                    chRes.Success = false;
                    chRes.Message = "For mode SQL-only this function not supported!";
                    L_chRes.Add(chRes);
                }
                result.Actions = L_chRes.ToArray();
                Logger.Trace(this, options, operationContext);
            }
            catch (Exception ex) { Logger.Error(ex); }
            return(result);
        }