Exemplo n.º 1
0
        public FertilizerOrganic_Info(int FertilizerOrganicKey)
        {
            string        zSQL = "SELECT * FROM PUL_FertilizerOrganic WHERE FertilizerOrganicKey = @FertilizerOrganicKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@FertilizerOrganicKey", SqlDbType.Int).Value = FertilizerOrganicKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _FertilizerOrganicKey = int.Parse(zReader["FertilizerOrganicKey"].ToString());
                    _Name        = zReader["Name"].ToString();
                    _Description = zReader["Description"].ToString();
                    if (zReader["CreatedBy"] != DBNull.Value)
                    {
                        _CreatedBy = Guid.Parse(zReader["CreatedBy"].ToString());
                    }
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    if (zReader["ModifiedBy"] != DBNull.Value)
                    {
                        _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    }
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }
            catch (Exception Err) { _Message = Err.ToString(); }
            finally { zConnect.Close(); }
        }
Exemplo n.º 2
0
        public TimeLimit_Cooperative_Info(int CooperativeKey, bool ok = true)
        {
            string        zSQL = "SELECT * FROM PUL_TimeLimit_Cooperative WHERE CooperativeKey = @CooperativeKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@CooperativeKey", SqlDbType.Int).Value = CooperativeKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _ID             = int.Parse(zReader["ID"].ToString());
                    _CooperativeKey = int.Parse(zReader["CooperativeKey"].ToString());
                    _TimeLimit      = int.Parse(zReader["TimeLimit"].ToString());
                    if (zReader["CreatedBy"] != DBNull.Value)
                    {
                        _CreatedBy = Guid.Parse(zReader["CreatedBy"].ToString());
                    }
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    if (zReader["ModifiedBy"] != DBNull.Value)
                    {
                        _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    }
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }
            catch (Exception Err) { _Message = Err.ToString(); }
            finally { zConnect.Close(); }
        }
Exemplo n.º 3
0
        public Member_Info(int Key)
        {
            string        zSQL = "SELECT * FROM PUL_Member WHERE Key = @Key";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@Key", SqlDbType.Int).Value = Key;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _Key             = int.Parse(zReader["Key"].ToString());
                    _MemID           = zReader["MemID"].ToString();
                    _Name            = zReader["Name"].ToString();
                    _Cooperative_Key = int.Parse(zReader["Cooperative_Key"].ToString());
                    _Address         = zReader["Address"].ToString();
                    _Email           = zReader["Email"].ToString();
                    _Phone           = zReader["Phone"].ToString();
                    _LatLng          = zReader["LatLng"].ToString();
                    _Description     = zReader["Description"].ToString();
                    _CreateBy        = int.Parse(zReader["CreateBy"].ToString());
                    if (zReader["CreateOn"] != DBNull.Value)
                    {
                        _CreateOn = (DateTime)zReader["CreateOn"];
                    }
                    _ModifiedBy = int.Parse(zReader["ModifiedBy"].ToString());
                    if (zReader["ModifiedOn"] != DBNull.Value)
                    {
                        _ModifiedOn = (DateTime)zReader["ModifiedOn"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }
            catch (Exception Err) { _Message = Err.ToString(); }
            finally { zConnect.Close(); }
        }
Exemplo n.º 4
0
        public string Update()
        {
            string zSQL = "UPDATE PUL_Fertilizers SET "
                          + " TradeName = @TradeName,"
                          + " UnitKey = @UnitKey,"
                          + " CommonKey = @CommonKey,"
                          + " CompanyKey = @CompanyKey,"
                          + " CategoryKey = @CategoryKey,"
                          + " UsingStatus = @UsingStatus,"
                          + " Images = @Images"
                          + " WHERE FertilizersKey = @FertilizersKey";
            string        zResult           = "";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@FertilizersKey", SqlDbType.Int).Value = _FertilizersKey;
                zCommand.Parameters.Add("@TradeName", SqlDbType.NVarChar).Value = _TradeName;
                zCommand.Parameters.Add("@UnitKey", SqlDbType.Int).Value        = _UnitKey;
                zCommand.Parameters.Add("@CommonKey", SqlDbType.Int).Value      = _CommonKey;
                zCommand.Parameters.Add("@CompanyKey", SqlDbType.Int).Value     = _CompanyKey;
                zCommand.Parameters.Add("@CategoryKey", SqlDbType.Int).Value    = _CategoryKey;
                zCommand.Parameters.Add("@UsingStatus", SqlDbType.Int).Value    = _UsingStatus;
                zCommand.Parameters.Add("@Images", SqlDbType.NVarChar).Value    = _Images;
                zResult = zCommand.ExecuteNonQuery().ToString();
                zCommand.Dispose();
            }
            catch (Exception Err)
            {
                _Message = Err.ToString();
            }
            finally
            {
                zConnect.Close();
            }
            return(zResult);
        }
Exemplo n.º 5
0
 public static void Set(ObjectId id, string key, object value)
 {
     try {
         if (id.IsErased == false & id.IsEffectivelyErased == false)
         {
             using (World.Docu.LockDocument()) {
                 using (Database db = World.Docu.Database) {
                     using (Transaction tr = db.TransactionManager.StartTransaction()) {
                         using (BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForWrite)) {
                             if (br.ExtensionDictionary == ObjectId.Null)
                             {
                                 br.CreateExtensionDictionary();
                             }
                             using (DBDictionary dict = (DBDictionary)tr.GetObject(br.ExtensionDictionary, OpenMode.ForWrite, false)) {
                                 DxfCode code = AcadIO.DxfHelper.GetFromObject(value);
                                 if (dict.Contains(key))
                                 {
                                     Xrecord      xRec   = (Xrecord)tr.GetObject(dict.GetAt(key), OpenMode.ForWrite);
                                     ResultBuffer resBuf = new ResultBuffer(new TypedValue(Convert.ToInt32(code), value));
                                     xRec.Data = resBuf;
                                 }
                                 else
                                 {
                                     Xrecord      xRec   = new Xrecord();
                                     ResultBuffer resBuf = new ResultBuffer(new TypedValue(Convert.ToInt32(code), value));
                                     xRec.Data = resBuf;
                                     dict.SetAt(key, xRec);
                                     tr.AddNewlyCreatedDBObject(xRec, true);
                                 }
                             }
                         }
                         tr.Commit();
                     }
                 }
             }
         }
     }
     catch (System.Exception ex) {
         Err.Log(ex);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Add Log Error
        /// </summary>
        private void Ae(Cx CurrCodeType, string Comments = null, Exception CurrExc = null, Mx CustomMethodContext = null)
        {
            if (C == null || C.L != true)
            {
                return;
            }

            Ce(CurrCodeType, CustomMethodContext);
            var r = new Err()
            {
                C = Comments
            };

            if (CurrCodeType != null)
            {
                r.X = CurrCodeType.CxId;
            }
            if (CustomMethodContext != null)
            {
                r.M = CustomMethodContext.CmId;
            }

            if (CurrExc != null)
            {
                r.Esr = CurrExc.Source;
                r.Em  = CurrExc.Message;
                if (S.S.Ea != true)
                {
                    r.Et  = CurrExc.StackTrace;
                    r.Es  = CurrExc.ToString();
                    r.Ets = CurrExc.TargetSite.ToString();
                }
            }
            L.E.Add(r);
            Rn++;

            if (Rl > 1 && Rn > Rl)
            {
                Sv();
            }
        }
Exemplo n.º 7
0
        /// <summary>this inserts a block into another block, the block designated by oid is the receiver and receives a new copy of the block designated by blockname</summary>
        public static Handle Insert(ObjectId oid, string blockPath, string blockName, Point3d position = new Point3d())
        {
            Handle hd = new Handle();

            try {
                if (oid.IsErased == false & oid.IsEffectivelyErased == false)
                {
                    using (World.Docu.LockDocument()) {
                        using (Database db = World.Docu.Database) {
                            using (Transaction tr = db.TransactionManager.StartTransaction()) {
                                using (BlockReference br = (BlockReference)tr.GetObject(oid, OpenMode.ForWrite)) {
                                    if (AcadIO.Insert.DB.AddBlock(blockPath + "\\" + blockName) == false)
                                    {
                                        return(hd);
                                    }

                                    using (BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead)) {
                                        using (BlockReference bi = new BlockReference(Autodesk.AutoCAD.Geometry.Point3d.Origin, bt[blockPath])) {
                                            using (BlockTableRecord blockSpace = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForWrite)) {
                                                blockSpace.AppendEntity(bi);
                                                tr.AddNewlyCreatedDBObject(bi, true);
                                                bi.LayerId  = br.LayerId;
                                                bi.Position = position;
                                                hd          = bi.Handle;
                                            }
                                        }
                                    }
                                }
                                tr.Commit();
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                Err.Log(ex);
            }
            finally {
            }
            return(hd);
        }
Exemplo n.º 8
0
        public async Task <GetAllStepVariableResponse> Get(GetAllStepVariableRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var step = await stepRepository.Get(request.BatchId, request.StepName);

            if (step == null)
            {
                throw Err.StepNotFound(request.StepName);
            }

            var response = new GetAllStepVariableResponse
            {
                Variables = step.Variables.ConvertTo <List <DomainModels.Variable> >()
            };

            return(response);
        }
Exemplo n.º 9
0
    //private void SaveEditSupplies()
    //{
    //    String Sql = "";

    //    for (int iSupply = 1; iSupply <= cSupplies; iSupply++)
    //    {
    //        TableRow tr = tblSupplies.Rows[iSupply];

    //        CheckBox chkRemove = (CheckBox)tr.FindControl("chkRemove" + iSupply);
    //        if (chkRemove != null && !chkRemove.Checked)
    //        {
    //            Int32 SupplySeq = Str.Num(WebPage.FindTextBox(ref tr, "txtSupplySeq" + iSupply));

    //            String SupplyItem = WebPage.FindTextBox(ref tr, "txtSupplyItem" + iSupply);
    //            String OrigSupplyItem = WebPage.FindTextBox(ref tr, "txtOrigSupplyItem" + iSupply);

    //            int Qty = Str.Num(WebPage.FindTextBox(ref tr, "txtQty" + iSupply));
    //            int OrigQty = Str.Num(WebPage.FindTextBox(ref tr, "txtOrigQty" + iSupply));

    //            String Note = WebPage.FindTextBox(ref tr, "txtNote" + iSupply);
    //            String OrigNote = WebPage.FindTextBox(ref tr, "txtOrigNote" + iSupply);

    //            if (SupplyItem != OrigSupplyItem ||
    //                Qty != OrigQty ||
    //                Note != OrigNote)
    //            {
    //                DateTime Tm = DateTime.Now;

    //                try
    //                {
    //                    if (SupplySeq == 0)
    //                    {
    //                        SupplySeq = db.NextSeq("mcJobSupplies", "JobRno", JobRno, "SupplySeq");

    //                        Sql =
    //                            "Insert Into mcJobSupplies (JobRno, SupplySeq, CreatedDtTm, CreatedUser) Values (" +
    //                            JobRno + ", " +
    //                            SupplySeq + ", " +
    //                            DB.PutDtTm(Tm) + ", " +
    //                            DB.PutStr(g.User) + ")";
    //                        db.Exec(Sql);
    //                    }

    //                    Sql =
    //                        "Update mcJobSupplies Set " +
    //                        "SupplyItem = " + DB.PutStr(SupplyItem, 50) + ", " +
    //                        "Qty = " + Qty + ", " +
    //                        "Note = " + DB.PutStr(Note, 128) + ", " +
    //                        "UpdatedDtTm = " + DB.PutDtTm(Tm) + ", " +
    //                        "UpdatedUser = "******" " +
    //                        "Where JobRno = " + JobRno + " " +
    //                        "And SupplySeq = " + SupplySeq;
    //                    db.Exec(Sql);
    //                }
    //                catch (Exception Ex)
    //                {
    //                    Err Err = new Err(Ex, Sql);
    //                    Response.Write(Err.Html());
    //                }
    //            }
    //        }
    //    }
    //}

    private void SaveShowSupplies()
    {
        String Sql     = "";
        bool   fInsert = false;

        try
        {
            Sql     = string.Format("Select Count(*) From mcJobSupplies Where JobRno = {0}", JobRno);
            fInsert = (db.SqlNum(Sql) == 0);
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }

        int iSupply = 0;

        SaveShowSuppliesTable(tblShowSupplies1, cShowSupplies1, ref iSupply, fInsert);
        SaveShowSuppliesTable(tblShowSupplies2, cShowSupplies2, ref iSupply, fInsert);
    }
Exemplo n.º 10
0
 public static bool CriaPath(string strPath)
 {
     try
     {
         if (Directory.Exists(strPath))
         {
             return(true);
         }
         else
         {
             Directory.CreateDirectory(strPath);
             return(true);
         }
     }
     catch (Exception Err)
     {
         ManipulaErro.MostraErro("EliminaArquivo():", Err.GetHashCode(), Err.Message, false);
         ManipulaErro.GravaEventLog("EliminaArquivo" + Err.Message, Err.GetHashCode());
         return(false);
     }
 }
Exemplo n.º 11
0
    protected string VendorData()
    {
        string        Sql = "Select VendorRno, Name From Vendors Where IsNull(HideFlg, 0) = 0 Order By Name";
        StringBuilder sb  = new StringBuilder();

        try
        {
            DataTable dt = db.DataTable(Sql);
            foreach (DataRow dr in dt.Rows)
            {
                sb.AppendFormat("{{label:'{0}',id:{1}}},", DB.Str(dr["Name"]).Replace("'", "\\'"), DB.Int32(dr["VendorRno"]));
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex);
            Response.Write(Err.Html());
        }

        return(string.Format("[{0}]", sb.ToString()));
    }
Exemplo n.º 12
0
 public void MergeFrom(SkillResponse other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Code != 0)
     {
         Code = other.Code;
     }
     if (other.err_ != null)
     {
         if (err_ == null)
         {
             err_ = new global::Msg.Error();
         }
         Err.MergeFrom(other.Err);
     }
     skills_.Add(other.skills_);
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Exemplo n.º 13
0
        public DataSet ReturnDataSet(string SQL, int StartIndex, int PageSize, string tablename)
        {
            DataSet Ds = new DataSet();

            try
            {
                this.GetDataAdapter(SQL).Fill(Ds, StartIndex, PageSize, tablename);
            }
            catch (Exception Err)
            {
                throw new Exception(SQL + Err.ToString());
            }
            finally
            {
                if (this.transaction == null)
                {
                    this.Close();
                }
            }
            return(Ds);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Uploads all log entries that contains an exception to codeRR.
 /// </summary>
 /// <param name="loggingEvent">The logging event.</param>
 protected override void Append(LoggingEvent loggingEvent)
 {
     LogsProvider.Instance.Add(new LogEntryDto(loggingEvent.TimeStampUtc, ConvertLevel(loggingEvent.Level), loggingEvent.RenderedMessage)
     {
         Exception = loggingEvent.ExceptionObject?.ToString(),
         Source    = loggingEvent.LoggerName,
     });
     if (loggingEvent.ExceptionObject == null)
     {
         return;
     }
     Err.Report(loggingEvent.ExceptionObject, new LogEntryDetails
     {
         LogLevel   = loggingEvent.Level.ToString(),
         Message    = loggingEvent.RenderedMessage,
         ThreadName = loggingEvent.ThreadName,
         Timestamp  = loggingEvent.TimeStamp,
         LoggerName = loggingEvent.LoggerName,
         UserName   = loggingEvent.UserName
     });
 }
Exemplo n.º 15
0
 public static void Delete(ObjectId oid)
 {
     try {
         if (oid.IsErased == false & oid.IsEffectivelyErased == false)
         {
             using (World.Docu.LockDocument()) {
                 using (Database db = World.Docu.Database) {
                     using (Transaction tr = db.TransactionManager.StartTransaction()) {
                         using (BlockReference br = (BlockReference)tr.GetObject(oid, OpenMode.ForWrite)) {
                             br.Erase();
                         }
                         tr.Commit();
                     }
                 }
             }
         }
     }
     catch (System.Exception ex) {
         Err.Log(ex);
     }
 }
Exemplo n.º 16
0
        public DataTable ReturnDataTable(string SQL)
        {
            DataTable dt = new DataTable();

            try
            {
                this.GetDataAdapter(SQL).Fill(dt);
            }
            catch (Exception Err)
            {
                throw new Exception(SQL + Err.ToString());
            }
            finally
            {
                if (this.transaction == null)
                {
                    this.Close();
                }
            }
            return(dt);
        }
Exemplo n.º 17
0
        public async Task <GetAllBatchArtifactOptionResponse> Get(GetAllBatchArtifactOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (batchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            var response = new GetAllBatchArtifactOptionResponse
            {
                Options = batchArtifact.Options.ConvertTo <List <DomainModels.Option> >()
            };

            return(response);
        }
Exemplo n.º 18
0
        public Soiltreatment_Info(int SoiltreatmentKey)
        {
            string        zSQL = "SELECT * FROM PUL_Soiltreatment WHERE SoiltreatmentKey = @SoiltreatmentKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@SoiltreatmentKey", SqlDbType.Int).Value = SoiltreatmentKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _SoiltreatmentKey = int.Parse(zReader["SoiltreatmentKey"].ToString());
                    if (zReader["Datetime"] != DBNull.Value)
                    {
                        _Datetime = (DateTime)zReader["Datetime"];
                    }
                    _AdditivesKey = int.Parse(zReader["AdditivesKey"].ToString());
                    _Quantity     = zReader["Quantity"].ToString();
                    _Howtouse     = zReader["Howtouse"].ToString();
                    _Area         = zReader["Area"].ToString();
                    _Weather      = zReader["Weather"].ToString();
                    _CreatedBy    = Guid.Parse(zReader["CreatedBy"].ToString());
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }catch (Exception Err) { _Message = Err.ToString(); }finally{ zConnect.Close(); }
        }
Exemplo n.º 19
0
        public HandlingPackaging_Info(int HandlingPackagingKey)
        {
            string        zSQL = "SELECT * FROM PUL_HandlingPackaging WHERE HandlingPackagingKey = @HandlingPackagingKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@HandlingPackagingKey", SqlDbType.Int).Value = HandlingPackagingKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _HandlingPackagingKey = int.Parse(zReader["HandlingPackagingKey"].ToString());
                    if (zReader["Datetime"] != DBNull.Value)
                    {
                        _Datetime = (DateTime)zReader["Datetime"];
                    }
                    _Type           = zReader["Type"].ToString();
                    _Place          = zReader["Place"].ToString();
                    _Treatment      = zReader["Treatment"].ToString();
                    _MemberKey      = int.Parse(zReader["MemberKey"].ToString());
                    _CooperativeKey = int.Parse(zReader["CooperativeKey"].ToString());
                    _CreatedBy      = Guid.Parse(zReader["CreatedBy"].ToString());
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }catch (Exception Err) { _Message = Err.ToString(); }finally{ zConnect.Close(); }
        }
Exemplo n.º 20
0
        public string Create()
        {
            //---------- String SQL Access Database ---------------
            string zSQL = "INSERT INTO PUL_CertifiedOrganization ("
                          + " CertifiedOrganization_ID ,CertifiedOrganization_Name ,CertificationType_Key ,Address ,Phone ,Fax ,Email ,Website ,Infrastructure ,Examination_Process ) "
                          + " VALUES ( "
                          + "@CertifiedOrganization_ID ,@CertifiedOrganization_Name ,@CertificationType_Key ,@Address ,@Phone ,@Fax ,@Email ,@Website ,@Infrastructure ,@Examination_Process ) ";
            string        zResult           = "";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@CertifiedOrganization_Key", SqlDbType.Int).Value       = _CertifiedOrganization_Key;
                zCommand.Parameters.Add("@CertifiedOrganization_ID", SqlDbType.NVarChar).Value   = _CertifiedOrganization_ID;
                zCommand.Parameters.Add("@CertifiedOrganization_Name", SqlDbType.NVarChar).Value = _CertifiedOrganization_Name;
                zCommand.Parameters.Add("@CertificationType_Key", SqlDbType.Int).Value           = _CertificationType_Key;
                zCommand.Parameters.Add("@Address", SqlDbType.NVarChar).Value             = _Address;
                zCommand.Parameters.Add("@Phone", SqlDbType.NVarChar).Value               = _Phone;
                zCommand.Parameters.Add("@Fax", SqlDbType.NVarChar).Value                 = _Fax;
                zCommand.Parameters.Add("@Email", SqlDbType.NVarChar).Value               = _Email;
                zCommand.Parameters.Add("@Website", SqlDbType.NVarChar).Value             = _Website;
                zCommand.Parameters.Add("@Infrastructure", SqlDbType.NVarChar).Value      = _Infrastructure;
                zCommand.Parameters.Add("@Examination_Process", SqlDbType.NVarChar).Value = _Examination_Process;
                zResult = zCommand.ExecuteNonQuery().ToString();
                zCommand.Dispose();
            }
            catch (Exception Err)
            {
                _Message = Err.ToString();
            }
            finally
            {
                zConnect.Close();
            }
            return(zResult);
        }
Exemplo n.º 21
0
        public CheckEquipment_Info(int CheckEquipmentKey)
        {
            string        zSQL = "SELECT * FROM PUL_CheckEquipment WHERE CheckEquipmentKey = @CheckEquipmentKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@CheckEquipmentKey", SqlDbType.Int).Value = CheckEquipmentKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _CheckEquipmentKey = int.Parse(zReader["CheckEquipmentKey"].ToString());
                    _EquipmentKey      = int.Parse(zReader["EquipmentKey"].ToString());
                    _Action            = zReader["Action"].ToString();
                    _Info = zReader["Info"].ToString();
                    if (zReader["Datetime"] != DBNull.Value)
                    {
                        _Datetime = (DateTime)zReader["Datetime"];
                    }
                    _MemberKey = int.Parse(zReader["MemberKey"].ToString());
                    _SeedsKey  = int.Parse(zReader["SeedsKey"].ToString());
                    _CreatedBy = Guid.Parse(zReader["CreatedBy"].ToString());
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }catch (Exception Err) { _Message = Err.ToString(); }finally{ zConnect.Close(); }
        }
Exemplo n.º 22
0
    private void Page_PreRender(object sender, System.EventArgs e)
    {
        hfNumConversions.Value = cConversions.ToString();

        string Sql = "Select VendorRno, Name From Vendors Where (HideFlg = 0 Or HideFlg Is Null) And Name <> '' Order By Name";

        try
        {
            ulPrefVendors.Controls.Clear();
            ulRejVendors.Controls.Clear();

            DataTable dt = DB.DBDataTable(Sql);

            foreach (DataRow dr in dt.Rows)
            {
                string   ID   = DB.Int32(dr["VendorRno"]).ToString();
                CheckBox chk1 = new CheckBox();
                CheckBox chk2 = new CheckBox();
                chk1.Text     =
                    chk2.Text = Server.HtmlEncode(DB.Str(dr["Name"]));
                chk1.ID       = "chkPrefVendor-" + ID;
                chk2.ID       = "chkRejVendor-" + ID;
                chk1.Attributes.Add("data-id", ID);
                chk2.Attributes.Add("data-id", ID);

                HtmlGenericControl li = new HtmlGenericControl("li");
                li.Controls.Add(chk1);
                ulPrefVendors.Controls.Add(li);

                li = new HtmlGenericControl("li");
                li.Controls.Add(chk2);
                ulRejVendors.Controls.Add(li);
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            Response.Write(Err.Html());
        }
    }
Exemplo n.º 23
0
        public Pesticide_Info(int PesticideKey)
        {
            string        zSQL = "SELECT * FROM PUL_Pesticides WHERE PesticideKey = @PesticideKey";
            string        zConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection zConnect          = new SqlConnection(zConnectionString);

            zConnect.Open();
            try
            {
                SqlCommand zCommand = new SqlCommand(zSQL, zConnect);
                zCommand.CommandType = CommandType.Text;
                zCommand.Parameters.Add("@PesticideKey", SqlDbType.Int).Value = PesticideKey;
                SqlDataReader zReader = zCommand.ExecuteReader();
                if (zReader.HasRows)
                {
                    zReader.Read();
                    _PesticideKey = int.Parse(zReader["PesticideKey"].ToString());
                    _Trade_Name   = zReader["Trade_Name"].ToString();
                    _Crop_Name    = zReader["Crop_Name"].ToString();
                    _Common_Key   = int.Parse(zReader["Common_Key"].ToString());
                    _CompanyKey   = int.Parse(zReader["CompanyKey"].ToString());
                    _CategoryKey  = int.Parse(zReader["CategoryKey"].ToString());
                    _UsingStatus  = int.Parse(zReader["UsingStatus"].ToString());
                    _Images       = zReader["Images"].ToString();
                    _CreatedBy    = Guid.Parse(zReader["CreatedBy"].ToString());
                    if (zReader["CreatedDateTime"] != DBNull.Value)
                    {
                        _CreatedDateTime = (DateTime)zReader["CreatedDateTime"];
                    }
                    _ModifiedBy = Guid.Parse(zReader["ModifiedBy"].ToString());
                    if (zReader["ModifiedDateTime"] != DBNull.Value)
                    {
                        _ModifiedDateTime = (DateTime)zReader["ModifiedDateTime"];
                    }
                }
                zReader.Close(); zCommand.Dispose();
            }
            catch (Exception Err) { _Message = Err.ToString(); }
            finally { zConnect.Close(); }
        }
Exemplo n.º 24
0
    private void Update()
    {
        bool     fNew = (hfNewRecords.Value == "true");
        DateTime Tm   = DateTime.Now;

        int Count = (int)Str.Int64(hfCount.Value);

        for (int iRow = 1; iRow <= Count; iRow++)
        {
            int    Seq          = Parm.Int("hfSeq" + iRow);
            string sDescription = Parm.Str("hfDescription" + iRow);
            string sCaterer     = Parm.Str("txtCaterer" + iRow);
            string sColor       = Parm.Str("txtColor" + iRow);
            string sOrdered     = Parm.Str("txtOrdered" + iRow);
            string sOther       = Parm.Str("txtOther" + iRow);

            string Sql = string.Format(fNew ?
                                       "Insert Into JobLinens (JobRno, Seq, Description, Caterer, Color, Ordered, Other, CreatedDtTm, CreatedUser) Values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})" :
                                       "Update JobLinens Set Caterer = {3}, Color = {4}, Ordered = {5}, Other = {6}, UpdatedDtTm = {7}, UpdatedUser = {8} Where JobRno = {0} and Seq = {1}",
                                       JobRno,
                                       Seq,
                                       DB.Put(sDescription, 20),
                                       DB.Put(sCaterer, 60),
                                       DB.Put(sColor, 20),
                                       DB.Put(sOrdered, 20),
                                       DB.Put(sOther, 60),
                                       DB.PutDtTm(Tm),
                                       DB.PutStr(g.User));

            try
            {
                db.Exec(Sql);
            }
            catch (Exception Ex)
            {
                Err Err = new Err(Ex, Sql);
                Response.Write(Err.Html());
            }
        }
    }
Exemplo n.º 25
0
        public CompanyInfo()
        {
            string nSQL = "SELECT * FROM SYS_CompanyInfo";

            string        nConnectionString = ConnectDataBase.ConnectionString;
            SqlConnection nConnect          = new SqlConnection(nConnectionString);

            nConnect.Open();
            try
            {
                SqlCommand nCommand = new SqlCommand(nSQL, nConnect);
                nCommand.CommandType = CommandType.Text;

                SqlDataReader nReader = nCommand.ExecuteReader();
                if (nReader.HasRows)
                {
                    nReader.Read();
                    m_CompanyName = nReader["CompanyName"].ToString();
                    m_Address     = nReader["Address"].ToString();


                    m_Tel     = nReader["Tel"].ToString();
                    m_Fax     = nReader["Fax"].ToString();
                    m_Email   = nReader["Email"].ToString();
                    m_Web     = nReader["Web"].ToString();
                    m_CodeTax = nReader["Tax"].ToString();
                    m_Logo    = (byte[])(nReader["Logo"]);
                }
                nReader.Close();
                nCommand.Dispose();
            }
            catch (Exception Err)
            {
                m_Message = Err.ToString();
            }
            finally
            {
                nConnect.Close();
            }
        }
Exemplo n.º 26
0
    public void AdjustStockedItemsQuantity(DB db)
    {
        string Sql = string.Format(
            //"Select StockedPurchaseQty, StockedPurchaseUnitQty, StockedPurchaseUnitRno, UnitSingle, UnitPlural " +
            //"From Ingredients i Left Join Units u on i.StockedPurchaseUnitRno = u.UnitRno " +
            "Select StockedPurchaseQty " +
            "From Ingredients " +
            "Where IngredRno = {0}",
            this.IngredRno);

        try
        {
            DataRow dr = db.DataRow(Sql);
            if (dr != null)
            {
                decimal Qty = DB.Dec(dr["StockedPurchaseQty"]);
                if (Qty != 0)
                {
                    //    decimal UnitQty = DB.Dec(dr["StockedPurchaseUnitQty"]);
                    //    this.Qty = Qty * (UnitQty != 0 ? UnitQty : 1);
                    //    this.UnitRno = DB.Int32(dr["StockedPurchaseUnitRno"]);
                    //    this.UnitSingle = DB.Str(dr["UnitSingle"]);
                    //    this.UnitPlural = DB.Str(dr["UnitPlural"]);

                    //    this.PurchaseQty = Qty;
                    //    this.PurchaseUnitQty = DB.Dec(dr["StockedPurchaseUnitQty"]);
                    //    this.PurchaseUnitRno = DB.Int32(dr["StockedPurchaseUnitRno"]);
                    //    this.PurchaseUnitSingle = DB.Str(dr["UnitSingle"]);
                    //    this.PurchaseUnitPlural = DB.Str(dr["UnitPlural"]);

                    this.StockedPurchaseQty = Qty;
                }
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            System.Web.HttpContext.Current.Response.Write(Err.Html());
        }
    }
Exemplo n.º 27
0
    /// <summary>
    /// Drops the item.
    /// </summary>
    /// <param name="context">The propositional context</param>
    /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
    /// <param name="src">The line number it was invoked</param>
    /// <param name="err">Where to place any descriptive error messages</param>
    /// <returns>True if was able interpret (it was sensible, even though can't be done), or false if not syntactically sensible</returns>
    bool drop(propositionContext context, List<object> items, SrcInFile src, Err err)
    {
        var from = (ZObject) player;
          // Check that we are holding the items
          List<ZObject> notHolding = new List<ZObject>();
          foreach (var item in items)
          {
         if (item is ZObject)
         {
            if (!((ZObject)item).isDescendentOf(from))
               notHolding.Add((ZObject)item);
         }
         else
         {
            // Format an error message
            err . linkTo(src);
            err.SB.AppendFormat("That doesn't makes sense... it isn't even a thing we can hold..");
            return false;
         }
          }
          if (notHolding.Count > 0)
          {
         // Not all of the items is there
         // Format an error message
         err . linkTo(src);
         err . SB . AppendFormat("{0} is not holding ", from.shortDescription);
         bool needComma = false;
         foreach (var item in notHolding)
         {
            // todo: add and
            err.SB.AppendFormat(needComma?", {0}":"{0}", item.shortDescription);
            needComma = true;
         }
         return false;
          }

          // Drop each of the items;
          // we do this by moving each of the items to the parent
          return move(((ZObject) player).Parent, items, src, err);
    }
Exemplo n.º 28
0
    public static void LoadVendors()
    {
        string Sql = "Select * From Vendors Order By VendorRno";

        try
        {
            DataTable dt = DB.DBDataTable(Sql);
            Vendors = new VendorData[dt.Rows.Count];
            int i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                Vendors[i].VendorRno = DB.Int32(dr["VendorRno"]);
                Vendors[i].Name      = DB.Str(dr["Name"]);
                i++;
            }
        }
        catch (Exception Ex)
        {
            Err Err = new Err(Ex, Sql);
            System.Web.HttpContext.Current.Response.Write(Err.Html());
        }
    }
Exemplo n.º 29
0
        /// <summary>
        /// 运行SQL语句,返回DataSet对象
        /// </summary>
        /// <param name="procName">SQL语句</param>
        /// <param name="prams">DataSet对象</param>
        /// <param name="dataReader">表名</param>
        public DataSet ReturnDataSet(string SQL, string tablename)
        {
            DataSet Ds = new DataSet();

            try
            {
                SQLiteDataAdapter Da = GetDataAdapter(SQL);
                Da.Fill(Ds, tablename);
            }
            catch (Exception Err)
            {
                throw new Exception(SQL + Err.ToString());
            }
            finally
            {
                if (null == transaction)
                {
                    Close();
                }
            }
            return(Ds);
        }
Exemplo n.º 30
0
 public static void UpdateWithLastPrice(int IngredRno)
 {
     try
     {
         Ingred.IngredPurchase Last = Ingred.LastPurchase(IngredRno);
         Ingred Ing = new Ingred(IngredRno);
         if (Last != null)
         {
             Ing.UpdatePrice(Last.Qty * Last.UnitQty, Last.UnitRno, Last.Price);
         }
         else
         {
             // not last price, remove the currently set price
             Ing.UpdatePrice();
         }
     }
     catch (Exception Ex)
     {
         Err Err = new Err(Ex);
         System.Web.HttpContext.Current.Response.Write(Err.Html());
     }
 }
Exemplo n.º 31
0
        /// <summary>
        /// 运行SQL语句,返回DataTable对象
        /// </summary>
        /// <param name="procName">SQL语句</param>
        public DataTable ReturnDataTable(string SQL)
        {
            DataTable dt = new DataTable();

            try
            {
                SQLiteDataAdapter Da = GetDataAdapter(SQL);
                Da.Fill(dt);
            }
            catch (Exception Err)
            {
                throw new Exception(SQL + Err.ToString());
            }
            finally
            {
                if (null == transaction)
                {
                    Close();
                }
            }
            return(dt);
        }
Exemplo n.º 32
0
 public static void make_(CancelledErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Exemplo n.º 33
0
 /// <summary>
 /// A helper to create a link to the text
 /// </summary>
 /// <param name="SB">The StringBuilder to append to</param>
 /// <param name="Line">The line number it was defined at</param>
 internal void LocalLinkTo(Err err, int Line)
 {
    err . SB . AppendFormat("<a href='#{0}'>", Line);
    err . SBEnd . Insert(0, "</a>");
 }
Exemplo n.º 34
0
 /// <summary>
 /// A helper to create a link to the original source
 /// </summary>
 /// <param name="SB">The StringBuilder to append to</param>
 /// <param name="Line">The line number it was defined at</param>
 internal static void InformLinkTo(Err err, int Line)
 {
    err. SB . AppendFormat("<a href='inform:{0}'>", Line);
    err. SBEnd . Insert(0, "</a>");
 }
Exemplo n.º 35
0
 public FileData(string name, Err error, string type)
 {
     this.Name = name;
     this.Error = error;
     this.Type = type;
 }
Exemplo n.º 36
0
 /// <summary>
 /// Describes the items listed
 /// </summary>
 /// <param name="context">The propositional context</param>
 /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
 /// <param name="src">The line number it was invoked</param>
 /// <param name="err">Where to place any descriptive error messages</param>
 /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
 bool look1(propositionContext context, List<object> items, SrcInFile src, Err err)
 {
     // Have the parent list it's children
       inventory(player, items[0]);
       return true;
 }
Exemplo n.º 37
0
		public void ReportError( Err errorLevel, Err errtype, string message)
		{
			this.lErrorType =errtype;
			this.lErrorInfo = message;
			if ( errtype <= errorLevel ) throw new Exception(message);
		}
Exemplo n.º 38
0
 public static new TimeoutErr make(string msg, Err cause)
 {
     TimeoutErr err = new TimeoutErr();
       make_(err, msg, cause);
       return err;
 }
Exemplo n.º 39
0
 public static void make_(TimeoutErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Exemplo n.º 40
0
   /// <summary>
   /// This is used to invoked the handler for the verb
   /// </summary>
   /// <param name="stmt">The statment to interpret</param>
   /// <param name="line">The line number it was invoked</param>
   /// <param name="err">Where to place any descriptive error messages</param>
   /// <returns>True on success, false on error</returns>
   bool interp(propositionContext ctxt,Lexer lexer, Err err)
   {
      // A reference to where the statement was made
      var src = new SrcInFile(null, lexer.Line);
      // See if there is a first noun, to whom the message is addressed
      var addressedTo = player;
      int matchLength  = 0;
      LexState lexerState = null;
      var tmp = matchInContext(((ZObject) player), lexer, out matchLength,
         ref lexerState);
      if (null != tmp && tmp is ZObject)
      {
         // Use the new object as the item to be commanded
         addressedTo = (ZObject) tmp;
         // Move past the words in that subphrase
         if (null != lexerState)
            lexer.Restore(lexerState);
      }

      // The handler for the different number of arguments
      dStatement[] handlers = null;

      // Find a matching verb phrase
      var phrase = findVerbPhrase(lexer);

      // Get the noun phrases
      var args = getNounPhrases(lexer, (ZObject) player, err);
      var n = null == args? 0: args.Count;

      // See if we need to guess the handler for the noun
      if (null == phrase)
      {
         // If there was nothing resolved about the nouns
         if (null == args)
            args = new List<object>();
         if (addressedTo != player)
         {
            // Move the "addressed to" back to the front
            addressedTo = player;
            args.Insert(0, tmp);
            n = args.Count;
         }

         // See if it said nothing
         if (0 == args.Count)
            return false;

         // See if the first item is a 
         tmp = args[0];

         // If it is a direction roll it around
         if (tmp is ZObject && !isKind((ZObject) tmp, dirKind))
         {
            // Format an error message
            err . linkTo(src);
            err . SB . AppendFormat("What do you mean?");
            return false;
         }

         // It is a direction 
         // Ok, lets just make it go?
         phrase = findVerbPhrase("go");
      }

      // If can't find the verb at all, complain
      if (null == phrase || !verbs.TryGetValue(phrase, out handlers))
      {
         // Format an error message
         err . linkTo(src);
         err . SB . AppendFormat("The verb isn't understood.");
         return false;
      }

      // If there isn't a form for that number of verbs, complain
      var h = n >= handlers . Length ? null : handlers[n];
      if (null == h)
      {
         err . linkTo(src);
         err . SB . AppendFormat("Verb '{0}' isn't known for that arity.", phrase);
         return false;
      }

      // Call the delegate
      return h(ctxt, args, src, err);
   }
Exemplo n.º 41
0
    /// <summary>
    /// Would "go" if a direction had been specified
    /// </summary>
    /// <param name="context">The propositional context</param>
    /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
    /// <param name="src">The line number it was invoked</param>
    /// <param name="err">Where to place any descriptive error messages</param>
    /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
    bool go(propositionContext context, List<object> items, SrcInFile src, Err err)
    {
        var dest = items[0];
          // Check that the destination is not the same as the current
          if (((ZObject)player).Parent == dest)
          {
         // Format an error message
         err . linkTo(src);
         err . SB . AppendFormat("We are already there.");
         return true;
          }

          // If it is an edge, get the door part
          if (dest is Edge<ZObject>)
          {
         var edge = (Edge<ZObject>) dest;
         // See if we can go into the room
         if (!canTraverseTo(edge))
         {
            // Format an error message
            err . linkTo(src);
            err . SB . AppendFormat("We can't go there.");
            return true;
         }
         dest = edge.sink;
          }

          // Check that the destination is a room
          if (isKind((ZObject)dest, cellKind))
          {
         // Make the move
         ((ZObject)player).Parent.RemoveChild((ZObject)player);
         ((ZObject)dest).AddChild(player);
         return true;
          }
          // See if it refers to a direction
          if (isKind((ZObject)dest, dirKind))
          {
         // Format an error message
         err . linkTo(src);
         err . SB . AppendFormat("There is nothing in the {0} direction!", ((ZObject)dest).shortDescription);
         return true;
          }
          // Format an error message
          err . linkTo(src);
          err . SB . AppendFormat("{0} is not a place!", dest);
          return true;
    }
Exemplo n.º 42
0
 /// <summary>
 /// Drops the item.
 /// </summary>
 /// <param name="context">The propositional context</param>
 /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
 /// <param name="src">The line number it was invoked</param>
 /// <param name="err">Where to place any descriptive error messages</param>
 /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
 bool get(propositionContext context, List<object> items, SrcInFile src, Err err)
 {
     // Drop each of the items;
       // we do this by moving each of the items to the parent
       return move((ZObject) player, items, src, err);
 }
Exemplo n.º 43
0
 public static new CancelledErr make(string msg, Err cause)
 {
     CancelledErr err = new CancelledErr();
       make_(err, msg, cause);
       return err;
 }
Exemplo n.º 44
0
 //////////////////////////////////////////////////////////////////////////
 // C# Constructors
 //////////////////////////////////////////////////////////////////////////
 public CancelledErr(Err.Val val)
     : base(val)
 {
 }
Exemplo n.º 45
0
 //////////////////////////////////////////////////////////////////////////
 // C# Constructors
 //////////////////////////////////////////////////////////////////////////
 public TimeoutErr(Err.Val val)
     : base(val)
 {
 }
Exemplo n.º 46
0
    bool move(ZObject to, List<object> items, SrcInFile src, Err err)
    {
        // Check that we have items that we can move
          if (null == items || items.Count < 1)
          {
         // Didn't specify the items to move
         // Format an error message
         err . linkTo(src);
         err . SB . AppendFormat("What should be moved?");
         return false;
          }

          // An array to hold the items that we can move
          var movables = new List<ZObject>();

          // Check that the movement is sane
          foreach (var item in items)
          {
         // Check that it is an item that we can move
         if (!(item is ZObject) || isKind((ZObject)item, cellKind) || isKind((ZObject)item, dirKind))
         {
            // Format an error message
            err . linkTo(src);
            err . SB . AppendFormat("That makes no sense.. we can't move that");
            return true;
         }
         var movable = (ZObject) item;
         if (movable . Parent == to)
         {
            // Format an error message
            err . linkTo(src);
            err . SB . AppendFormat("That makes no sense.. that doesn't really move an item anywhere!");
            return true;
         }
         movables.Add(movable);
          }

          // Reparent each of the items now
          foreach (var item in movables)
          {
         item.Parent.RemoveChild(item);
         to.AddChild(item);
          }

          return true;
    }
Exemplo n.º 47
0
 /// <summary>
 /// Would "go" if a direction had been specified
 /// </summary>
 /// <param name="context">The propositional context</param>
 /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
 /// <param name="src">The line number it was invoked</param>
 /// <param name="err">Where to place any descriptive error messages</param>
 /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
 bool goWhere(propositionContext context, List<object> items, SrcInFile src, Err err)
 {
     // Format an error message
       err . linkTo(src);
       err . SB . AppendFormat("Go where?");
       return true;
 }
Exemplo n.º 48
0
 /// <summary>
 /// Describes the items being carried.
 /// </summary>
 /// <param name="context">The propositional context</param>
 /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
 /// <param name="src">The line number it was invoked</param>
 /// <param name="err">Where to place any descriptive error messages</param>
 /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
 bool inventory(propositionContext context, List<object> items, SrcInFile src, Err err)
 {
     // List the contents of the player character
       inventory(player, (ZObject) player);
       return true;
 }
Exemplo n.º 49
0
 /// <summary>
 /// A helper to (typically) create a link to the original source
 /// </summary>
 /// <param name="SB">The StringBuilder to append to</param>
 /// <param name="Line">The line number it was defined at</param>
 internal static void NoLinkTo(Err err, int Line)
 {
 }
Exemplo n.º 50
0
   /// <summary>
   /// Gets the objects referred to by each of the noun phrases
   /// </summary>
   /// <param name="lexer">The lexer that provides the input</param>
   /// <param name="addressedTo"></param>
   /// <param name="err"></param>
   /// <returns></returns>
   List<object> getNounPhrases(Lexer lexer, ZObject addressedTo, Err err)
   {
      // The list of referred to objects
      var ret = new List<object>();
      lexer.Preprocess();

      // Map the rest of the words to nouns
      while (!lexer.EOF)
      {
         int matchLength  = 0;
         LexState lexerState = null;
         // Match the next noun phrase
         var t = matchInContext(addressedTo, lexer, out matchLength, ref lexerState);
         // 5. if no noun was mapped
         if (null == t)
         {
            // Try the main relations (isa)

            // error could not understand at index
            err . SB . AppendFormat("The phrase \"{0}\" isn't understood.", 
                                    lexer.ToEndOfLine().Trim());
            return null;
         }

         // Save the noun phrase
         ret.Add(t);

         // Move past the words in that subphrase
         if (null != lexerState)
            lexer.Restore(lexerState);
         lexer.Preprocess();
      }

      return ret;
      // couldNotUnderstand(string, startingAt);
      // isAmbiguous(words);
   }
Exemplo n.º 51
0
 /// <summary>
 /// Would drop an item if one had been specified
 /// </summary>
 /// <param name="context">The propositional context</param>
 /// <param name="items">The direct objects,  indirect objects, and other noun phrase</param>
 /// <param name="src">The line number it was invoked</param>
 /// <param name="err">Where to place any descriptive error messages</param>
 /// <returns>True if was able interpret (it was sensible, even though can't be don), or false if not syntactically sensible</returns>
 bool dropWhat(propositionContext context, List<object> items, SrcInFile src, Err err)
 {
     // Format an error message
       err . linkTo(src);
       err . SB . AppendFormat("Drop what?");
       return true;
 }
Exemplo n.º 52
0
		public void setDriverErrorLevel(Err Value)
		{
			this.commandProcessor.ExceptionLevel = Value;		
		}
Exemplo n.º 53
0
 /// <summary>
 /// Interprete and carry out the statement
 /// </summary>
 /// <param name="lexer">The lexer for the input</param>
 /// <returns>True if interpreted, false if not</returns>
 public bool interp(Lexer lexer)
 {
    Console.WriteLine("> {0}", lexer.Str);
    // Create something to hold the error
    var err = new Err(Err.NoLinkTo);
    // Interpret this
    var ret = interp (null, lexer, err);
    // Emit the error message
    Console.WriteLine(err.ToString());
    return ret;
 }