Esempio n. 1
0
        private async void SaveAndConnect()
        {
            try
            {
                ConnectionCore xMLCore = new ConnectionCore();
                if (EditModel != null)
                {
                    EditModel = xMLCore.Connections.FirstOrDefault(x => x.Connection.ConnectionName == EditModel.ConnectionName)?.Connection;

                    EditModel.ConnectionName = ConnModel.ConnectionName;
                    EditModel.ConnType       = ConnModel.ConnType;
                    EditModel.Host           = ConnModel.Host;
                    EditModel.Port           = ConnModel.Port;
                    EditModel.UserName       = ConnModel.UserName;
                    EditModel.Password       = ConnModel.Password;
                    EditModel.BuilderBuildConnection();
                }
                else
                {
                    ConnModel.BuilderBuildConnection();
                    xMLCore.Connections.Insert(0, new TreeViewModel()
                    {
                        Connection = ConnModel
                    });
                }
                xMLCore.ConnectionSerialize();
            }
            catch (Exception ex)
            {
                await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  /r/nStackTrace: {ex.StackTrace}");
            }
        }
Esempio n. 2
0
        public LoginAPIController()
        {
            ConnModel obj = objGetConn.GetConstr();

            dbName      = obj.Db;
            invDbName   = obj.InvDb;
            enttConstr  = obj.EnttConnStr;
            AppConstr   = obj.AppConnStr;
            InvConstr   = obj.InvConnStr;
            WRPartyCode = obj.WRPartyCode;
        }
Esempio n. 3
0
        //Accordig to new schema Inventory Db
        //public User ValidateUser(LoginModel model)
        //{
        //    User objResponse = new User();
        //    try
        //    {
        //        using(var entity=new InventoryEntities( objGetConn.GetConstr().EnttConnStr))
        //        {
        //            objResponse = (from result in entity.Inv_M_UserMaster
        //                           where result.ActiveStatus == "Y" && result.UserName.ToLower() == model.UserName.ToLower() && result.Passw.ToLower() == model.password.ToLower()
        //                           join ledger in entity.M_LedgerMaster on result.BranchCode equals ledger.PartyCode
        //                           join groupid in entity.M_GroupMaster on ledger.GroupId equals groupid.GroupId
        //                           select new User
        //                           {
        //                                UserId=(int)result.UserId,
        //                                UserName=result.UserName,
        //                                Password=result.Passw,
        //                                 BranchCode=result.BranchCode,
        //                                  PartyCode=ledger.PartyCode,
        //                                   PartyName=ledger.PartyName,
        //                                    GroupId=(int)ledger.GroupId,
        //                                     FCode=ledger.PartyCode,
        //                                      StateCode= (int)ledger.StateCode
        //                           }

        //                         ).FirstOrDefault();
        //        }
        //    }
        //    catch(Exception ex)
        //    {

        //    }
        //    //if (string.IsNullOrEmpty(objResponse.UserName))
        //    //{
        //    //    objResponse = null;
        //    //}
        //    return objResponse;
        //}

        public ConnModel GetCompDetail()
        {
            ConnModel objCon = new ConnModel();

            try
            {
                objCon = objGetConn.GetConstr();
            }
            catch (Exception)
            {
            }
            return(objCon);
        }
Esempio n. 4
0
        public ConnModel GetDistBillInfo()
        {
            string        Constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["MasterDB"].ConnectionString;
            SqlConnection SC     = new SqlConnection(Constr);
            ConnModel     objcon = new ConnModel();

            try
            {
                objcon = GetConstr();
                string query = "Select * FROM DbCaptions WHERE CompID='" + objcon.CompID + "' AND IsActive='1'";
                SC.Open();
                SqlCommand    cmd = new SqlCommand(query, SC);
                SqlDataReader Dr  = cmd.ExecuteReader();

                if (Dr.Read())
                {
                    objcon.FirstActivationBill = Dr["FirstActivationBill"].ToString();
                    objcon.FirstBillOnMRP      = Dr["FirstBillOnMRP"].ToString();
                    objcon.FirstBillMinAmt     = Convert.ToDecimal(Dr["FirstBillMinAmt"].ToString());
                    objcon.FirstBillMinBV      = Convert.ToDecimal(Dr["FirstBillMinBV"].ToString());
                    objcon.FirstBillMinPV      = Convert.ToDecimal(Dr["FirstBillMinPV"].ToString());

                    objcon.FirstBillonBV  = Dr["FirstBillonBV"].ToString().ToUpper();
                    objcon.FirstBillonAmt = Dr["FirstBillonAmt"].ToString().ToUpper();
                    objcon.FirstBillonPV  = Dr["FirstBillonPV"].ToString().ToUpper();
                    objcon.FirstIDUpgrade = Dr["FirstIDUpgrade"].ToString().ToUpper();

                    objcon.ShowInvType = Dr["ShowInvType"].ToString().ToUpper();
                    objcon.ShowOffers  = Dr["ShowOffers"].ToString().ToUpper();

                    objcon.ShowActiveBV  = Dr["ShowActiveBV"].ToString().ToUpper();
                    objcon.ShowRepurchBV = Dr["ShowRepurchBV"].ToString().ToUpper();
                    objcon.ShowActivePV  = Dr["ShowActivePV"].ToString().ToUpper();
                    objcon.ShowRepurchPV = Dr["ShowRepurchPV"].ToString().ToUpper();

                    objcon.WalletType = Dr["WalletType"].ToString().ToUpper();
                }
                Dr.Close();
                SC.Close();
            }
            catch (Exception)
            {
                if (SC.State == ConnectionState.Open)
                {
                    SC.Close();
                }
            }
            return(objcon);
        }
Esempio n. 5
0
        private bool CheckConnection()
        {
            try
            {
                IDbConnection connection;
                ConnModel.BuilderBuildConnection();

                switch (ConnModel.ConnType)
                {
                case ConnectionTypes.MySQL:
                    connection = new MySqlConnection(ConnModel.ConnString);
                    connection.Open();
                    connection.Close();
                    break;

                case ConnectionTypes.SQL_CE:
                    connection = new SqlConnection(ConnModel.ConnString);
                    connection.Open();
                    connection.Close();
                    break;

                case ConnectionTypes.SQL_Server:
                    connection = new SqlConnection(ConnModel.ConnString);
                    connection.Open();
                    connection.Close();
                    break;

                case ConnectionTypes.PostgreSQL:
                    connection = new NpgsqlConnection(ConnModel.ConnString);
                    connection.Open();
                    connection.Close();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                exception = ex;
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        public ConnModel GetConstr()
        {
            ConnModel objcon = new ConnModel();

            try
            {
                //System.Web.HttpContext.Current.Session["DBName"] = "VisionRoots";
                //System.Web.HttpContext.Current.Session["AppDBConStr"] = "Data Source=103.74.54.49;Initial Catalog=VisionRoots;Integrated Security=False;User Id=usrvisn;Password=Su$n!428P#t;";
                //System.Web.HttpContext.Current.Session["InvDBConStr"] = "Data Source=103.74.54.49;Initial Catalog=VRInv;Integrated Security=False;User Id=usrvisn;Password=Su$n!428P#t;";
                //System.Web.HttpContext.Current.Session["enttConStr"] = BuildConnectionString(System.Web.HttpContext.Current.Session["InvDBConStr"].ToString());

                string Constr  = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["MasterDB"].ConnectionString;
                string ImgPath = System.Web.Configuration.WebConfigurationManager.AppSettings["ImgPath"];
                // string compid = System.Web.Configuration.WebConfigurationManager.AppSettings["CompID"];
                string compid = "0";
                string URL    = System.Web.HttpContext.Current.Request.Url.Host.ToUpper().Replace("HTTP://", "").Replace("HTTPS://", "").Replace("WWW.", "").Replace("/", "").Replace("BASICFRANCHISE.", "").Replace("FRANCHISE.", "");// System.Web.HttpContext.Current.Request.UserHostName;
                string query;

                System.Web.HttpContext.Current.Session["URL"] = URL;
                if (URL == "LOCALHOST")
                {
                    compid = System.Web.Configuration.WebConfigurationManager.AppSettings["TmpCompID"];
                    query  = "Select a.*,'" + ImgPath + "'+ b.Logo as Logo FROM M_ConnectionMaster a, M_CompanyMasterNew b WHERE a.CompanyID=b.ID AND a.CompanyID='" + compid + "' AND a.IsActive='1'";
                }
                else
                {
                    query = "Select a.*,'" + ImgPath + "'+ b.Logo as Logo FROM M_ConnectionMaster a, M_CompanyMasterNew b WHERE a.CompanyID=b.ID AND b.URL='" + URL + "' AND a.IsActive='1'";
                }

                SqlConnection SC = new SqlConnection(Constr);

                //string query = "Select a.*,'"+ ImgPath + "'+ b.Logo as Logo FROM M_ConnectionMaster a, M_CompanyMasterNew b WHERE a.CompanyID=b.ID AND (b.URL='" + URL + "' OR ('"+ URL +"'='LOCALHOST' AND b.ID='"+ compid +  "'))  AND a.IsActive='1'";
                SqlCommand cmd = new SqlCommand();

                DataTable Dt = new DataTable();
                try
                {
                    SC.Open();
                    cmd.CommandText = query;
                    cmd.Connection  = SC;
                    SqlDataAdapter Da = new SqlDataAdapter(cmd);
                    Da.Fill(Dt);
                    SC.Close();
                }
                catch (Exception ex)
                {
                    if (SC.State == ConnectionState.Open)
                    {
                        SC.Close();
                    }
                }

                //query = "UPDATE M_CompanyMasterNew SET CrntURL='" + System.Web.HttpContext.Current.Request.Url.Host + "; " + System.Web.HttpContext.Current.Request.UserHostName + "' WHERE ID=3";
                //SC.Open();
                //cmd = new SqlCommand(query,SC);
                //cmd.ExecuteNonQuery();
                //SC.Close();

                if (Dt.Rows.Count > 0)// || (URL=="LOCALHOST"))
                {
                    compid = Dt.Rows[0]["CompanyID"].ToString();

                    objcon.CompID   = compid;
                    objcon.LogoPath = Dt.Rows[0]["Logo"].ToString();
                    for (var i = 0; i < Dt.Rows.Count; i++)
                    {
                        if (Convert.ToInt32(Dt.Rows[i]["ConnTypeID"].ToString()) == 2)
                        {
                            objcon.InvConnStr  = Dt.Rows[i]["ConnectionString"].ToString();
                            objcon.InvDb       = Dt.Rows[i]["DatabaseName"].ToString();
                            objcon.EnttConnStr = BuildConnectionString(Dt.Rows[i]["ConnectionString"].ToString());
                        }

                        if (Convert.ToInt32(Dt.Rows[i]["ConnTypeID"].ToString()) == 1)
                        {
                            objcon.AppConnStr = Dt.Rows[i]["ConnectionString"].ToString();
                            objcon.Db         = Dt.Rows[i]["DatabaseName"].ToString();
                        }
                    }


                    query = "Select * FROM DbCaptions WHERE CompID='" + compid + "' AND IsActive='1'";
                    SC.Open();
                    cmd = new SqlCommand(query, SC);
                    SqlDataReader Dr = cmd.ExecuteReader();

                    if (Dr.Read())
                    {
                        objcon.BVCaption   = Dr["BVCaption"].ToString();
                        objcon.CVCaption   = Dr["CVCaption"].ToString();
                        objcon.PVCaption   = Dr["PVCaption"].ToString();
                        objcon.RPCaption   = Dr["RPCaption"].ToString();
                        objcon.WRPartyCode = Dr["WRPartyCode"].ToString();
                        objcon.CompName    = Dr["CompName"].ToString();
                    }
                    Dr.Close();
                    SC.Close();
                }
            }
            catch (Exception ex)
            {
            }
            if (objcon != null)
            {
                System.Web.HttpContext.Current.Session["ConModel"] = objcon;
            }

            return(objcon);
        }