Exemple #1
0
        //===================================== Add Brand =====================================//
        static public SportModels.ResponseModel Api_Sport_Brand_Add_BLL(SportModels.BrandModel BM)
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();

            try
            {
                //lay du lieu tu DAL, return
                SportModels.DALOutput DALO = new SportModels.DALOutput();

                DALO = CSqlSport.Api_Sport_Brand_Add_DAL(BM);

                // response info (success)
                RM.Code    = DALO.ErrorCode;
                RM.Message = DALO.ErrorMessage;
                RM.Data    = DALO.SqlData;
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // response info (error)
                RM.Code    = CBase.GetLayerErrorCode(CBase.LAYER.BLL);
                RM.Message = ex.Message;
                RM.Data    = null;
            }

            // return
            return(RM);
        }
Exemple #2
0
        public OverlayRenderer(Process g, CBase b)
        {
            watch = new Stopwatch();

            game        = g;
            Master      = b;
            mouseDown   = false;
            move        = false;
            overlay     = new OverlayWindow(false);
            tealBrush   = overlay.Graphics.CreateBrush(System.Drawing.Color.FromArgb(80, 0, 255, 255));
            blackBrush  = overlay.Graphics.CreateBrush(System.Drawing.Color.FromArgb(80, 0, 0, 0));
            blackBrush2 = overlay.Graphics.CreateBrush(System.Drawing.Color.FromArgb(130, 0, 0, 0));
            redBrush    = overlay.Graphics.CreateBrush(System.Drawing.Color.FromArgb(130, 255, 0, 0));
            mousePos    = new POINT()
            {
                X = 0, Y = 0
            };
            font      = overlay.Graphics.CreateFont("Arial", 15);
            fontSmall = overlay.Graphics.CreateFont("Arial", 12, true);
            titleFont = overlay.Graphics.CreateFont("Arial", 18, true);

            doLoop = true;

            Yoffset = 0;
            Xoffset = 0;
            Xshift  = 0;
            Yshift  = 350;
        }
Exemple #3
0
    /// <summary>
    /// Use Coroutine to initialize the two base modules: Resource & UI
    /// </summary>
    IEnumerator DoInit()
    {
        ICModule[] baseModules = new ICModule[] {  // 基础三件套
            CResourceManager.Instance,
            CUIManager.Instance,
        };
        foreach (ICModule mod in baseModules)
        {
            yield return(StartCoroutine(mod.Init()));
        }

        CBase.Log("Finish Init ResourceManager + UIManager!");

        if (BeforeInitModules != null)
        {
            yield return(StartCoroutine(BeforeInitModules()));
        }


        yield return(StartCoroutine(DoInitModules()));

        if (AfterInitModules != null)
        {
            yield return(StartCoroutine(AfterInitModules()));
        }
    }
Exemple #4
0
    public object GetControl(Type type, string uri, Transform findTrans = null, bool isLog = true)
    {
        if (findTrans == null)
        {
            findTrans = transform;
        }

        Transform trans = findTrans.Find(uri);

        if (trans == null)
        {
            if (isLog)
            {
                CBase.LogError("Get UI Control Error: " + uri);
            }
            return(null);
        }

        if (type == typeof(GameObject))
        {
            return(trans.gameObject);
        }

        return(trans.GetComponent(type));
    }
    static void CheckConfigFile()
    {
        if (!File.Exists(ConfFilePath))
        {
            CTabFile confFile = new CTabFile();
            confFile.NewRow();
            confFile.NewColumn("Key");
            confFile.NewColumn("Value");
            confFile.NewColumn("Comment");


            foreach (string[] strArr in DefaultConfigFileContent)
            {
                int row = confFile.NewRow();
                confFile.SetValue <string>(row, "Key", strArr[0]);
                confFile.SetValue <string>(row, "Value", strArr[1]);
                confFile.SetValue <string>(row, "Comment", strArr[2]);
            }
            confFile.Save(ConfFilePath);

            CBase.Log("新建CosmosEngine配置文件: {0}", ConfFilePath);
            AssetDatabase.Refresh();
        }

        ConfFile = CTabFile.LoadFromFile(ConfFilePath);
    }
Exemple #6
0
        //===================================== Delete Category =====================================//
        public static SportModels.DALOutput Api_Sport_Category_Delete_DAL(SportModels.CategoryModel CM)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlParameter[] arrParams = new SqlParameter[1];

                // input params
                arrParams[0]           = new SqlParameter("categoryID", SqlDbType.Int);
                arrParams[0].Direction = ParameterDirection.Input;
                arrParams[0].Value     = CM.CategoryID;

                // exec
                ds = SqlHelper.ExecuteDataset(CConfigDS.CONNECTION_STRING_SQL_SPORT_SHOP, CommandType.StoredProcedure, CConfigDS.SPORT_SHOP_SQL_SP_CATEGORY_DELETE, arrParams);

                // return (neu sp ko tra error code,msg thi tu gan default)
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CConfigDS.RESPONSE_CODE_SUCCESS, ErrorMessage = CConfigDS.RESPONSE_MSG_SUCCESS, SqlData = ds
                });
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // error => return null
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CBase.GetLayerErrorCode(CBase.LAYER.DAL), ErrorMessage = ex.Message, SqlData = null
                });
            }
        }
Exemple #7
0
        public HttpResponseMessage Api_Sport_Category_Search( )
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();
            SportModels.CategoryModel CM = new SportModels.CategoryModel();
            try
            {
                // ?categoryName={CategoryName}&createdDate={CreatedDate}
                var varUrlKeyValues = ControllerContext.Request.GetQueryNameValuePairs();

                // lay cac value can thiet tu queryString
                CM.CategoryName = varUrlKeyValues.LastOrDefault(x => x.Key == "categoryName").Value;
                CM.CreatedDate  = Convert.ToDateTime(varUrlKeyValues.LastOrDefault(x => x.Key == "createdDate").Value);

                // 1. get data
                RM = CSport.Api_Sport_Category_Search_BLL(CM);

                // 2. return response (code 200)
                return(CreateJsonResponse(RM));
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // return error code
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
    IEnumerator StartDownload(string fullUrl)
    {
        float startTime = Time.time;

        while (!WWWLoader.IsFinished)
        {
            if (WWWLoader.Progress == 0 && Time.time - startTime > TIME_OUT_DEF)
            {
                CBase.LogError("超時卻無下載 Timeout: {0}", fullUrl);
                break;
            }

            yield return(null);
        }
        if (WWWLoader.IsError || !WWWLoader.IsFinished)
        {
            CBase.LogError("Download WWW Error: {0}", fullUrl);
            ForceFinished = true;
            ForceError    = true;
            yield break;
        }

        string dir = Path.GetDirectoryName(_SavePath);

        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }

        System.IO.File.WriteAllBytes(_SavePath, WWWLoader.Www.bytes);
    }
Exemple #9
0
        /// <summary>
        /// Thuc hien 1 store procedure (co tham so) tra ve 1 DataReader
        /// Input:
        ///       1. spName: ten store
        ///       2. myParamArray() : danh sach cac tham so
        /// Output: DataReader
        /// </summary>
        /// <param name="SPname">sp_SELECT</param>
        /// <returns></returns>
        public SqlDataReader GetDataReaderFromSP(string SPname)
        {
            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = SPname;
            m_Command.CommandType = CommandType.StoredProcedure;
            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());      // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_DataReader       = m_Command.ExecuteReader();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                return(m_DataReader);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(null);
            }
            finally
            {
                //_CloseConnection(); // _CloseConnection thi error, phai goi CloseConnection tu ben ngoai (Caller)
            }
        }
Exemple #10
0
        /// <summary>
        /// Thuc hien 1 câu lệnh sql tra ve 1 DataReader
        /// Input:
        ///       1. câu lệnh sql
        /// Output: DataReader
        /// </summary>
        /// <param name="SQL">select * from tbl_test</param>
        /// <returns></returns>
        public SqlDataReader GetDataReaderFromQuery(string myQuery)
        {
            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = myQuery;
            m_Command.CommandType = CommandType.Text;
            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), myQuery);                           // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_DataReader       = m_Command.ExecuteReader();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                return(m_DataReader);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(null);
            }
            finally
            {
                //_CloseConnection(); // _CloseConnection thi error, phai goi CloseConnection tu ben ngoai (Caller)
            }
        }
Exemple #11
0
        /// <summary>
        /// Thuc hien 1 cau query tra ve 1 dataset
        /// Input:
        ///         1. Ten store procedure
        /// Output: dataset
        /// </summary>
        /// <returns></returns>
        public DataSet GetDatasetFromSP(string SPname)
        {
            DataSet functionReturnValue = null;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(null);
            }
            DataSet ds = new DataSet();

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());    // log SQL

                m_Command.Connection  = m_Connection;
                m_Command.CommandText = SPname;
                m_Command.CommandType = CommandType.StoredProcedure;
                DateTime dtBegin = DateTime.Now; // duration
                m_DataAdapter = new SqlDataAdapter(m_Command);
                m_DataAdapter.Fill(ds);
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                functionReturnValue = ds;
            }
            catch (Exception ex)
            {
                functionReturnValue = null;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
    void OnAssetBundleLoaded(string url, AssetBundle assetBundle, params object[] args)
    {
        Object asset = null;

        System.DateTime beginTime = System.DateTime.Now;
        if (AssetInBundleName == null)
        {
            // 经过AddWatch调试,.mainAsset这个getter第一次执行时特别久,要做序列化
            try
            {
                asset = assetBundle.mainAsset;
            }
            catch
            {
                CBase.LogError("[OnAssetBundleLoaded:mainAsset]{0}", url);
            }
        }
        else
        {
            AssetBundleRequest request = assetBundle.LoadAsync(AssetInBundleName, typeof(Object));
            asset = request.asset;
        }

        CResourceManager.LogLoadTime("AssetFileBridge", url, beginTime);

        if (asset == null)
        {
            CBase.LogError("Asset is NULL: {0}", url);
        }

        AssetFileLoadedCallback(asset, CallbackArgs);
    }
        public bool checkPermission(DataTable dt, string str, string action)
        {
            bool result = false;

            DataRow[] dtSelect = new DataRow[dt.Rows.Count];
            try
            {
                dtSelect = dt.Select("Model = '" + str + "'");
                foreach (DataRow row in dtSelect)
                {
                    if (row[action].ToString() == "1")
                    {
                        if (result == false)
                        {
                            result = true;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                //if (dt.Select("Model = '"+ str +"'")[0][action].ToString() == "True")
            }
            catch (Exception ex)
            {
                result = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(result);
        }
Exemple #14
0
 void Awake()
 {
     if (_Instance != null)
     {
         CBase.Assert(_Instance == this);
     }
 }
        /// <summary>
        /// get set room
        /// </summary>
        /// <param name="BookingCode"></param>
        /// <returns></returns>
        public JsonResult GetRoomForReservationRoom(string BookingCode)
        {
            List <string> json = new List <string>();
            DataSet       ds   = new DataSet();

            try
            {
                UserID    = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                HotelCode = Session[CConfig.SESSION_HOTELCODE].ToString();
                if (HotelCode == null)
                {
                    Response.Redirect("Receptionist/BookingList");
                }
                json = data.GetReservationRoom_Detail(BookingCode, HotelCode, UserID);
                ////ds = data.GetReservationRoom_Detail( BookingCode, HotelCode, UserID);
                ////Thông tin đặt phòng
                //ViewData["BookingInfo"] = json[0];
                //// thong tin phong
                //ViewData["SetRoom"] = json[1];
                ////Thông tin khách hàng
                //ViewData["CustomerInfo"] = json[2];
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(Json(new { mess = json }, JsonRequestBehavior.AllowGet));
        }
Exemple #16
0
        public bool readDataSynchronous2(CBase cBaseCommand, out int nLen)
        {
            nLen = 0;
            int  packageLength = _packageLength;
            bool readOK;

            try
            {
                readOK = inEndpoint.XferData(ref _receiveBuf, ref packageLength);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            if (readOK)
            {
                if (packageLength >= 10)
                {
                    nLen = packageLength;
                    return(true);
                }
                ProcessError(cBaseCommand, "USB has receive data ,but the data length has less than 10,the data length error.");
            }
            else
            {
                ProcessError(cBaseCommand, "Read data from USB time out error.");
            }

            return(false);
        }
        // GET: Group/Detail/5
        public ActionResult DetailBooking(string BookingCode)
        {
            List <string> json = new List <string>();
            DataSet       ds   = new DataSet();

            try
            {
                UserID    = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);
                HotelCode = Session[CConfig.SESSION_HOTELCODE].ToString();

                //Lấy danh sách giá thời điểm
                ViewData["giathoidiem"] = new SelectList(data.GetList_DefineCategory("GIATHOIDIEM", UserID), "Value", "Name");
                //Lấy danh sách khung giá phòng
                ViewData["khunggiaphong"] = new SelectList(data.GetList_DefineCategory("KHUNGGIAPHONG", UserID), "Value", "Name");

                if (HotelCode == null)
                {
                    Response.Redirect("Receptionist/BookingList");
                }
                json = data.GetReservationRoom_Detail(BookingCode, HotelCode, UserID);
                //ds = data.GetReservationRoom_Detail( BookingCode, HotelCode, UserID);
                //Thông tin đặt phòng
                ViewData["BookingInfo"] = json[0];
                // thong tin phong
                ViewData["SetRoom"] = json[1];
                //Thông tin khách hàng
                ViewData["CustomerInfo"] = json[2];
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(View());
        }
Exemple #18
0
        /// <summary>
        /// 2015-05-04 14:41:33 ngocta2
        /// chi can read 1 dong
        /// </summary>
        /// <param name="strFullPathTemplate"></param>
        /// <returns></returns>
        public static string ReadFile(string strFullPathTemplate)
        {
            try
            {
                // C:\Log\5G_QuoteFeeder_HOSE\SQL\2014_12_04.txt
                string strPath = strFullPathTemplate
                                 .Replace("(AppName)", CConfig.BASE_APP_NAME)
                                 .Replace("(yyyy)", DateTime.Now.Year.ToString())
                                 .Replace("(MM)", CBase.Right("00" + DateTime.Now.Month.ToString(), 2))
                                 .Replace("(dd)", CBase.Right("00" + DateTime.Now.Day.ToString(), 2))
                ;

                // check folder
                CheckDirectory(strPath);

                // read
                string strBody = "";
                using (StreamReader sr = new StreamReader(strPath))
                {
                    strBody = sr.ReadToEnd();
                }

                return(strBody);
            }
            catch (Exception)
            {
                // do nothing
                return("");
            }
            finally
            {
            }
        }
Exemple #19
0
        //===============================================================================================================

        #region Execute
        /// <summary>
        /// ExecuteQuery
        /// Thuc hien 1 cau lenh Insert, Update, Delete, hay 1 procedure = cach viet cau lenh "exec sp_fgsd"
        /// Input: cau lenh sql
        /// Output: Boolean (thanh cong hay khong ?)
        /// </summary>
        /// <param name="SQL">delect * from tbl_test</param>
        /// <param name="SQL">exec sp_fgsd</param>
        /// <returns></returns>
        public bool ExecuteQuery(string myQuery)
        {
            bool functionReturnValue = false;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(false);
            }

            m_Command.CommandTimeout = this.m_CommandTimeout;
            m_Command.Connection     = m_Connection;
            m_Command.CommandText    = myQuery;
            m_Command.CommandType    = CommandType.Text;

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), myQuery);                            // log SQL

                DateTime dtBegin = DateTime.Now;                                        // duration
                m_Command.ExecuteNonQuery();
                this.m_dblDuration  = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                functionReturnValue = true;
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
Exemple #20
0
    public T GetInfo <T>(string id) where T : CBaseInfo
    {
        EnsureLoad <T>();

        Dictionary <string, CBaseInfo> dict;

        if (SettingInfos.TryGetValue(typeof(T), out dict))
        {
            CBaseInfo tabInfo;
            if (dict.TryGetValue(id, out tabInfo))
            {
                return((T)tabInfo);
            }
            else
            {
                CBase.LogError("找不到类型{0} Id为{1}的配置对象, 类型表里共有对象{2}", typeof(T).Name, id, dict.Count);
            }
        }
        else
        {
            CBase.LogError("嘗試Id {0}, 找不到类型配置{1}, 总类型数{2}", id, typeof(T).Name, SettingInfos.Count);
        }

        return(null);
    }
Exemple #21
0
    /// <summary>
    /// Use Coroutine to initialize the two base modules: Resource & UI
    /// </summary>
    IEnumerator DoInit()
    {
        ICModule[] baseModules = new ICModule[] {  // 基础三件套
            CResourceManager.Instance,
            CUIManager.Instance,
        };
        foreach (ICModule mod in baseModules)
        {
            float startInitTime = Time.time;
            yield return(StartCoroutine(mod.Init()));

            if (Debug.isDebugBuild)
            {
                CBase.Log("Init Module: #{0}# Time:{1}", mod.GetType().FullName, Time.time - startInitTime);
            }
        }

        CBase.Log("Finish Init ResourceManager + UIManager!");

        if (BeforeInitModules != null)
        {
            yield return(StartCoroutine(BeforeInitModules()));
        }


        yield return(StartCoroutine(DoInitModules()));

        if (AfterInitModules != null)
        {
            yield return(StartCoroutine(AfterInitModules()));
        }
    }
        public JsonResult DeleteGroupMenu(string ID)
        {
            string result, resultC;

            try
            {
                DataSet ds     = new DataSet();
                int     iID    = string.IsNullOrEmpty(ID) ? 0 : Int32.Parse(ID.ToString());
                int     UserID = Session[CConfig.SESSION_USERID].ToString() == "" ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                ds = data.DeleteGroupMenuRel(iID, UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    result  = ds.Tables[0].Rows[0][0].ToString();
                    resultC = ds.Tables[0].Rows[0][1].ToString();
                }
                else
                {
                    result  = "Error: Xóa Menu không thành công";
                    resultC = "-1";
                }
            }
            catch (Exception ex)
            {
                result  = "Error: Không thêm được menu vào group";
                resultC = "";
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }

            return(Json(new { mess = result, code = resultC }, JsonRequestBehavior.AllowGet));
        }
        // GET: Group/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                GroupModels Group = new GroupModels();
                UserID = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                Group = data.GetGroupByID(id);
                ViewData["ListRule"] = data.GetAccessRights(id);
                TempData["MenuList"] = new SelectList(data.GetListMenu(), "ID", "Name");
                TempData.Keep("MenuList");

                ViewData["ListGroupType"] = new SelectList(data.GetGroupTypeList(UserID), "ID", "NameVN", Group.GroupType);
                ViewData["Hotel"]         = new SelectList(dataNam.getListHotels(), "Code", "Name", Group.SysHotelCode);

                TempData["ListGroupMenu"] = data.GetListGroupMenu(id);
                TempData.Keep("ListGroupMenu");
                return(View(Group));
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(View());
            }
        }
Exemple #24
0
        private void frmC机械手_MouseDown(object sender, MouseEventArgs e)
        {
            int    i      = 0;
            PointF MouseP = new PointF(e.X, e.Y);;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                for (i = ListTuYuan.Count - 1; i > -1; i--)
                {
                    CBase obj = (CBase)ListTuYuan[i];
                    if (obj.ElementType == LCElementType.Ring)
                    {
                        if (obj.Selected(MouseP))
                        {
                            CRing nRing = (CRing)obj;

                            string       sVar = "AV" + nRing.ShowText.PadLeft(3, '0');
                            CStation     Sta  = frmMain.staComm.GetStaByStaName("NJ301");
                            CProtcolFINS SPLC = (CProtcolFINS)Sta;
                            SPLC.SendAODO(sVar, 0, "DO");
                            break;
                        }
                    }
                }
            }
        }
Exemple #25
0
        //Ham nay thuc hien viec ket noi voi database
        //COMMAND => The time in seconds to wait for the command to execute. The default is 30 seconds.
        public bool _OpenConnection()
        {
            bool functionReturnValue = false;

            try
            {
                if (m_Connection == null || m_Connection.State == ConnectionState.Closed) // 2015-07-16 09:33:40 ngocta2 => bug: open 2 connection, close 1
                {
                    // CHUA OPEN roi thi tao new connection
                    m_Connection = new SqlConnection(this.m_ConnectionString);
                    m_Connection.Open();
                    functionReturnValue = true;
                }
                else
                {
                    if (m_Connection.State == ConnectionState.Open)
                    {
                        // OPEN roi thi ko tao connection nua
                        functionReturnValue = true;
                    }
                }
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            return(functionReturnValue);
        }
Exemple #26
0
        /// <summary>
        /// 2016-07-19 08:50:25 ngocta2
        /// chi log hanh dong AddItemToSortedSet
        /// Z_KEY, Z_VALUE, Z_SCORE
        ///Log(CConfig.BASE_LOG_PATH_TEXT, strTitle, strDetail);
        ///<!-- C:\Log\MyApp\TEXT\2014\05\17\1gzjxwqq.p0b   |  C:\Log\MyApp\TEXT\2014-05-17.txt -->
        ///<add key="BASE_LOG_PATH_TEXT" value="C:\Log\(AppName)\TEXT\(yyyy)\(MM)\(dd)\" />
        ///<!-- C:\Log\MyApp\TYPE\2014\05\17\1_SECURITY_14_22_59__1gzjxwqq.txt -->
        ///<add key="BASE_LOG_PATH_EX" value="C:\Log\(AppName)\LogEx\(yyyy)\(MM)\(dd)\(FileName)" />
        ///15:21:34.843^20160719090544764^{"Time":"09:05:44","Data":{"TimeJS":"1468893900000","Index":"86.99","Vol":"111500"}}
        /// </summary>
        /// <param name="strFileNameEx"></param>
        /// <param name="strBody"></param>
        public static void LogRedis(string strZKey, double dblZScore, string strZValue)
        {
            try
            {
                string strPath = CConfig.BASE_LOG_PATH_TEXT
                                 .Replace("(AppName)", CConfig.BASE_APP_NAME)
                                 .Replace("(yyyy)", DateTime.Now.Year.ToString())
                                 .Replace("(MM)", CBase.Right("00" + DateTime.Now.Month.ToString(), 2))
                                 .Replace("(dd)", CBase.Right("00" + DateTime.Now.Day.ToString(), 2));

                // check folder
                CheckDirectory(strPath);

                // noi them filename, chu y error
                //LE:S5G_ACM => error
                strPath += strZKey.Replace(":", "___") + ".js";

                // tao body
                string strBody = Convert.ToInt64(dblZScore).ToString() + "^" + strZValue;

                // write
                StreamWriter fs = new StreamWriter(strPath, true); // append
                //15:21:34.843^20160719090544764^{"Time":"09:05:44","Data":{"TimeJS":"1468893900000","Index":"86.99","Vol":"111500"}}
                fs.WriteLine(DateTime.Now.ToString("HH:mm:ss.") + DateTime.Now.Millisecond.ToString("000") + "^" + strBody);
                fs.Close();
            }
            catch (Exception)
            {
                // do nothing
            }
            finally
            {
            }
        }
Exemple #27
0
        /// <summary>
        /// ExecuteSP
        /// Thuc hien 1 store procedure Insert, Update, Delete
        /// Input: 1. spName: ten store
        ///        2. myParamArray() : mang cac tham so truyen va
        /// Output: Boolean (thanh cong hay khong ?)
        /// </summary>
        /// <param name="SPname">sp_DELETE_ALL</param>
        /// <returns></returns>
        public bool ExecuteSP(string SPname)
        {
            bool functionReturnValue = false;

            if ((_OpenConnection() == false))           // Open Connection
            {
                return(false);
            }

            m_Command.Connection  = m_Connection;
            m_Command.CommandText = SPname;
            m_Command.CommandType = CommandType.StoredProcedure;

            try
            {
                CLog.LogSQL(CBase.GetDeepCaller(), SPname + this.GetParamInfo());      // log SQL

                DateTime dtBegin = DateTime.Now;                                       // duration
                m_Command.ExecuteNonQuery();
                this.m_dblDuration = DateTime.Now.Subtract(dtBegin).TotalMilliseconds; // duration
                m_Command.Parameters.Clear();
                functionReturnValue = true;
            }
            catch (Exception ex)
            {
                functionReturnValue = false;
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
            }
            finally
            {
                _CloseConnection();     // Close Connection
            }
            return(functionReturnValue);
        }
Exemple #28
0
        /// <summary>
        /// 2015-05-04 14:32:33 ngocta2
        /// </summary>
        /// <param name="strFullPathTemplate"></param>
        /// <param name="strBody"></param>
        /// <param name="blnIsAppend"></param>
        public static void WriteFile(string strFullPathTemplate, string strBody, bool blnIsAppend)
        {
            try
            {
                // C:\Log\5G_QuoteFeeder_HOSE\SQL\2014_12_04.txt
                string strPath = strFullPathTemplate
                                 .Replace("(AppName)", CConfig.BASE_APP_NAME)
                                 .Replace("(yyyy)", DateTime.Now.Year.ToString())
                                 .Replace("(MM)", CBase.Right("00" + DateTime.Now.Month.ToString(), 2))
                                 .Replace("(dd)", CBase.Right("00" + DateTime.Now.Day.ToString(), 2))
                ;

                // check folder
                CheckDirectory(strPath);

                // write
                StreamWriter fs = new StreamWriter(strPath, blnIsAppend); // append
                fs.WriteLine(strBody);
                fs.Close();
            }
            catch (Exception)
            {
                // do nothing
            }
            finally
            {
            }
        }
Exemple #29
0
        public void BeginWrite(CBase cBaseCommand, string usage, AsyncCallback callback)
        {
            EventHandler <UsbReaderEventArgs> eh = new EventHandler <UsbReaderEventArgs>(Sendasy);
            UsbReaderEventArgs e = new UsbReaderEventArgs(usage, cBaseCommand);

            eh.BeginInvoke(this, e, callback, eh);
        }
Exemple #30
0
 private bool IsCommandNeedRecordLog(CBase cBaseCommand)
 {
     return(true);
     //return !(cBaseCommand is C11 || cBaseCommand is C58 || cBaseCommand is C18 ||
     //         cBaseCommand is C67 || cBaseCommand is C22 || cBaseCommand is C68 ||
     //         cBaseCommand is CED || cBaseCommand is C58_2 || cBaseCommand is C68_2 ||
     //         cBaseCommand is C05_2);
 }
Exemple #31
0
        public void DifferentConceptSameKey()
        {
            var a1 = new CBase { Name = "A", Info = "1" };
            var a2 = new CBase { Name = "A", Info = "2" };
            var b1 = new CBase { Name = "B", Info = "1" };

            var a1_x = new CDerived { Name = "A", Info = "1", Info2 = "x" };
            var a1_y = new CDerived { Name = "A", Info = "1", Info2 = "y" };
            var a3_x = new CDerived { Name = "A", Info = "3", Info2 = "x" };

            TestDifferentConceptSameKey(new ListOfTuples<IConceptInfo[], string, string, string[]>
            {
                { new IConceptInfo[] { a1_x }, "CDerived A", "CDerived A", null },
                { new IConceptInfo[] { a1, b1 }, "CBase B", "CBase B, CDerived A", null }, // a1 is a base concept for a1_x, and has same values of the mutual properties, so it will be ignored.
            });

            TestDifferentConceptSameKey(new ListOfTuples<IConceptInfo[], string, string, string[]>
            {
                { new IConceptInfo[] { a1_x }, "CDerived A", "CDerived A", null },
                { new IConceptInfo[] { a2 }, null, null, new[] { "DslSyntaxException", "different values", "CDerived A 1 x", "CBase A 2" } }, // a1_x is a derivation of a2, but has different values of the mutual properties.
            });

            TestDifferentConceptSameKey(new ListOfTuples<IConceptInfo[], string, string, string[]>
            {
                { new IConceptInfo[] { a3_x }, "CDerived A", "CDerived A", null },
                { new IConceptInfo[] { a1 }, null, null, new[] { "DslSyntaxException", "different values", "CDerived A 3 x", "CBase A 1" } }, // a1_x is a derivation of a2, but has different values of the mutual properties.
            });

            TestDifferentConceptSameKey(new ListOfTuples<IConceptInfo[], string, string, string[]>
            {
                { new IConceptInfo[] { a1_x }, "CDerived A", "CDerived A", null },
                { new IConceptInfo[] { a1_y }, null, null, new[] { "DslSyntaxException", "different values", "CDerived A 1 x", "CDerived A 1 y" } },
            });

            TestDifferentConceptSameKey(new ListOfTuples<IConceptInfo[], string, string, string[]>
            {
                { new IConceptInfo[] { a1_x }, "CDerived A", "CDerived A", null },
                { new IConceptInfo[] { a3_x }, null, null, new[] { "DslSyntaxException", "different values", "CDerived A 1 x", "CDerived A 3 x" } },
            });
        }