public IEnumerable <DyncForm> GetDyncFormByName(string name)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where name = '{name}' and IsDelete=0";
            return(_dyncForm.Query(condition));
        }
        public IEnumerable <DyncForm> GetDyncForm()
        {
            var condition = new SQLCondition();

            condition.Expression = "where IsDelete=0 order by Updatetime desc";
            return(_dyncForm.Query(condition: condition));
        }
Exemple #3
0
        QueryBuilder IRepositoryDependent <CuentaMayor> .GetDependentByMasterSelectSQL(int dependentIdCodigo, IEnumerable <int> ids)
        {
            Type         t        = GetObjModelType();
            QueryBuilder qBuilder = new QueryBuilder();
            //var ownerConditions = GetCurrentOwnersCondition(tableAlias: "cuenta");
            var joinCondition = new SQLCondition("Id", "cuenta", "IdCuenta", "apu");
            var owners        = new string[2] {
                "IdOwnerComunidad", "IdOwnerEjercicio"
            };
            IEnumerable <string> inParams = ids
                                            .Select(x =>
                                                    x.ToString().PutAhead("inP"));

            qBuilder
            //SELECT apu.Apunte FROM apunte apu WHERE apu.Id IN(ids);
            .Select(t, "apu")
            .SelectColumns(owners, "cuenta")
            .From(t, "apu")
            //.Join("INNER", typeof(CuentaMayor), "cuenta")
            //.On(joinCondition)
            //.AddWhere(ownerConditions)
            .Where(new SQLCondition("Id", "apu", inParams))    // "@codCuenta", ""))
            .SemiColon();

            //qBuilder.StoreParameter("codCuenta", dependentIdCodigo);
            //qBuilder.StoreParameter("idCdad", base.CurrentCdadOwner);
            //qBuilder.StoreParameter("idEjer", base.CurrentEjerOwner);
            qBuilder.StoreParameters((IEnumerable <object>)ids, "inP");

            return(qBuilder);
        }
Exemple #4
0
        QueryBuilder IRepositoryDependent <CuentaMayor> .GetAllDependentByMasterSelectSQL(int dependentIdCodigo)
        {
            Type         t                    = GetObjModelType();
            QueryBuilder qBuilder             = new QueryBuilder();
            var          ownerConditions      = GetCurrentOwnersCondition(tableAlias: "cuenta");
            var          joinCuentaCondition  = new SQLCondition("Id", "cuenta", "IdCuenta", "apu");
            var          joinAsientoCondition = new SQLCondition("Id", "asi", "Asiento", "apu");
            var          owners               = new string[2] {
                "IdOwnerComunidad", "IdOwnerEjercicio"
            };

            qBuilder
            //SELECT apu.Apunte, cuenta.owners FROM apunte apu INNER JOIN cuentamayor cuenta ON cuenta.Id = apu.IdCuenta
            //WHERE cuenta.IdOwnerComunidad = @idCdad AND cuenta.IdOwnerEjercicio = @idEjer AND apu.IdCuenta = @codCuenta;
            .Select(t, "apu")
            .SelectColumns(owners, "cuenta")
            .From(t, "apu")
            .Join("INNER", typeof(CuentaMayor), "cuenta")
            .On(joinCuentaCondition)
            .Where(ownerConditions)
            .Condition("AND ", new SQLCondition("IdCuenta", "apu", "@codCuenta", ""))
            .SemiColon();

            qBuilder.StoreParameter("codCuenta", dependentIdCodigo);
            qBuilder.StoreParameter("idCdad", base.CurrentCdadOwner);
            qBuilder.StoreParameter("idEjer", base.CurrentEjerOwner);

            return(qBuilder);
        }
        public SQLPage <DyncForm> GetDyncFormByName(int pageSize, int currentPage, string name)
        {
            var condition = new SQLCondition();

            condition.Expression = "where name like '%" + name + "%' and IsDelete=0 order by Updatetime desc";
            return(_dyncForm.Query(pageSize, currentPage, condition));
        }
Exemple #6
0
        public Site GetSiteById(int id)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where Id  = {id}";
            return(_site.Query(condition).SingleOrDefault());
        }
Exemple #7
0
        QueryBuilder IRepositoryDependent <CuentaMayor> .GetDependentByMasterSelectSQL(int dependentIdCodigo, IEnumerable <int> ids)
        {
            Type                 t                   = GetObjModelType();
            Type                 apunte              = typeof(Apunte);
            QueryBuilder         qBuilder            = new QueryBuilder();
            var                  joinApunteCondition = new SQLCondition("Asiento", "apu", "Id", "asi");
            IEnumerable <string> inParams            = ids
                                                       .Select(x =>
                                                               x.ToString().PutAhead("inP"));

            //SELECT asi.asiento, apu.apunte FROM asiento asi
            //INNER JOIN apunte apu ON apu.Asiento = asi.Id -> joinApuntecondition
            //WHERE asi.Id IN(ids)
            qBuilder
            .Select(t, "asi")
            .SelectColumns(apunte, "apu")
            .Join("INNER", apunte, "apu")
            .On(joinApunteCondition)
            .Where(new SQLCondition("Id", "asi", inParams))
            .OrderBy(new string[1] {
                "Fecha"
            }, "asi")
            .OrderBy(new string[1] {
                "OrdenEnAsiento"
            }, "apu")
            .SemiColon();
            qBuilder.StoreParameters((IEnumerable <object>)ids, "inP");

            return(qBuilder);
        }
Exemple #8
0
        public SQLPage <Site> GetSiteByName(string name, int pageSize, int currentPage)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where name like '%{name}%' and IsDelete=0 order by Updatetime desc";
            return(_site.Query(pageSize, currentPage, condition));
        }
Exemple #9
0
        /// <summary>
        /// 执行查询返回DataSet
        /// </summary>
        /// <param name="TableName">表名</param>
        /// <param name="ConditionForSelect">自定义条件</param>
        /// <param name="PageIndex">页索引号</param>
        /// <returns>Dataset</returns>
        public DataSet GetDSQuery(string TableName, SQLCondition ConditionForSelect, params string[] FieldNames)
        {
            int        MaxCount = 0;
            DataHelper dh       = new DataHelper(_DataBaseName);

            return(GetDSQuery(dh, TableName, ConditionForSelect != null ? ConditionForSelect.ToString(dh) : string.Empty, -1, -1, ref MaxCount, FieldNames));
        }
Exemple #10
0
        public SQLPage <Site> GetSite(int pageSize, int currentPage)
        {
            var condition = new SQLCondition();

            condition.Expression = "where IsDelete=0 order by Updatetime desc";
            return(_site.Query(pageSize, currentPage, condition));
        }
Exemple #11
0
        public IEnumerable <Site> GetSiteByName(string name)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where name = '{name}' and IsDelete=0 order by Updatetime desc";
            return(_site.Query(condition));
        }
Exemple #12
0
        public SiteTemp GetSiteTempById(int Id)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where Id = {Id} and IsDelete=0 ";
            return(_siteTemp.Query(condition).FirstOrDefault());
        }
Exemple #13
0
        public IEnumerable <SiteResource> GetSiteSiteResourceBySiteId(int siteId)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where SiteId = {siteId} and IsDelete=0 order by Updatetime desc";
            return(_siteResource.Query(condition));
        }
Exemple #14
0
        protected override void OnLoad(EventArgs e)
        {
            // Get list of series in view
            SQLCondition conditions = new SQLCondition();

            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.Equal);
            CheckedItems = DBSeries.Get(conditions);

            // Get list of series not in view
            conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.NotEqual);
            UnCheckedItems = DBSeries.Get(conditions);

            // Populate series list,
            // mark as checked at top of list
            foreach (DBSeries series in CheckedItems)
            {
                checkedListBoxSeries.Items.Add(series, true);
            }

            foreach (DBSeries series in UnCheckedItems)
            {
                checkedListBoxSeries.Items.Add(series, false);
            }

            CheckedCount             = CheckedItems.Count;
            labelSeriesSelected.Text = CheckedCount.ToString() + " Series Selected";

            this.checkedListBoxSeries.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBoxSeries_ItemCheck);
            base.OnLoad(e);
        }
        public int QueryMultiMOMemoCount(
            string itemcodes, string mos, string startRCard, string endRCARD,
            string startMemo, string endMemo)
        {
            string sql = string.Format(@"select count( * ) from TBLONWIP where action = '{0}' and length(eattribute1)>0 ",
                                       ActionType.DataCollectAction_GoMO);

            if (itemcodes != null && itemcodes.Length > 0)
            {
                sql += string.Format(" and itemcode in ({0}) ", FormatHelper.ProcessQueryValues(itemcodes));
            }

            if (mos != null && mos.Length > 0)
            {
                sql += string.Format(" and MoCode in ({0}) ", FormatHelper.ProcessQueryValues(mos));
            }

            sql += FormatHelper.GetRCardRangeSql("RCARD", startRCard, endRCARD);

            sql += FormatHelper.GetCodeRangeSql("EAttribute1", startMemo, endMemo);

            SQLCondition sqlCondition = new SQLCondition(sql);

#if DEBUG
            Log.Info(sqlCondition.SQLText);
#endif
            return(this.DataProvider.GetCount(sqlCondition));
        }
Exemple #16
0
        private void buttonSeriesIgnore_Click(object sender, EventArgs e)
        {
            SeriesSelect SeriesSelectDlg = new SeriesSelect();

            // Get list of series in view
            SQLCondition conditions = new SQLCondition();

            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.Equal);
            SeriesSelectDlg.CheckedItems = DBSeries.Get(conditions);

            // Get list of series not in view
            conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.NotEqual);
            SeriesSelectDlg.UnCheckedItems = DBSeries.Get(conditions);

            // Show series list dialog
            DialogResult result = SeriesSelectDlg.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                foreach (DBSeries series in SeriesSelectDlg.CheckedItems)
                {
                    // ignore these series
                    series[DBOnlineSeries.cTraktIgnore] = 1;
                    series.Commit();
                }

                foreach (DBSeries series in SeriesSelectDlg.UnCheckedItems)
                {
                    // unignore these series
                    series[DBOnlineSeries.cTraktIgnore] = 0;
                    series.Commit();
                }
            }
        }
Exemple #17
0
        public VLogin Login(string login, string password)
        {
            var condition   = new SQLCondition();
            var dbParameter = new DbParameter[] {
                new SqlParameter()
                {
                    DbType = DbType.String, Value = login, ParameterName = "@login"
                },
            };

            condition.Expression = "where name = @login or  Email = @login or Phone=@login";
            var user   = _user.Query(condition, dbParameter);
            var vLogin = new VLogin();

            if (!user.Any())
            {
                vLogin.IsLogin    = false;
                vLogin.LoginStats = LoginStats.NAME;
                return(vLogin);
            }
            var item = user.Where(t => t.Password.Equals(password.GetMd5Str())).SingleOrDefault();

            if (item == null)
            {
                vLogin.IsLogin    = false;
                vLogin.LoginStats = LoginStats.PASSOWRD;
                return(vLogin);
            }
            vLogin.IsLogin    = true;
            vLogin.LoginStats = LoginStats.SUCCESS;
            vLogin.User       = item;
            return(vLogin);
        }
Exemple #18
0
        public SQLPage <VUser> GetUserByName(int page, int current, string name)
        {
            var condition = new SQLCondition();

            condition.Expression = "where name like '%" + name + "%'";
            return(ConverToVUser(_user.Query(page, current, condition)));
        }
        private void buttonSeriesSelect_Click(object sender, EventArgs e)
        {
            SeriesSelect SeriesSelectDlg = new SeriesSelect();

            // Set Current View
            string viewTag = "|" + txtViewName.Text + "|";;

            // Get list of series in view
            SQLCondition conditions = new SQLCondition();

            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, viewTag, SQLConditionType.Like);
            SeriesSelectDlg.CheckedItems = DBSeries.Get(conditions);

            // Get list of series not in view
            conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, viewTag, SQLConditionType.NotLike);
            SeriesSelectDlg.UnCheckedItems = DBSeries.Get(conditions);

            // Show series list dialog
            DialogResult result = SeriesSelectDlg.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                SeriesToAdd    = SeriesSelectDlg.CheckedItems;
                SeriesToRemove = SeriesSelectDlg.UnCheckedItems;
            }
        }
        /// <summary>
        /// Get a series id by show name
        /// </summary>
        /// <param name="seriesName">Name of the series to look for</param>
        /// <returns>A series id or null if none was found</returns>
        public static int?GetSeriesIdByName(string seriesName)
        {
            SQLCondition conditions = new SQLCondition();

            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cPrettyName, seriesName, SQLConditionType.Like);
            List <DBSeries> seriesList = DBSeries.Get(conditions);

            // Return best matching series or null if no result was found
            if (seriesList.Count == 1)
            {
                return(seriesList[0][DBOnlineSeries.cID]);
            }
            else if (seriesList.Count > 1)
            {
                foreach (DBSeries series in seriesList)
                {
                    if (series[DBOnlineSeries.cPrettyName].Equals(seriesName))
                    {
                        return(series[DBOnlineSeries.cID]);
                    }
                }

                return(seriesList[0][DBOnlineSeries.cID]);
            }
            else
            {
                return(null);
            }
        }
        private void buttonSeriesIgnore_Click(object sender, EventArgs e)
        {
            SeriesSelect SeriesSelectDlg = new SeriesSelect();

            // Get list of series in view
            SQLCondition conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.Equal);            
            SeriesSelectDlg.CheckedItems = DBSeries.Get(conditions);

            // Get list of series not in view
            conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 1, SQLConditionType.NotEqual);            
            SeriesSelectDlg.UnCheckedItems = DBSeries.Get(conditions);

            // Show series list dialog
            DialogResult result = SeriesSelectDlg.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                foreach (DBSeries series in SeriesSelectDlg.CheckedItems)
                {
                    // ignore these series
                    series[DBOnlineSeries.cTraktIgnore] = 1;
                    series.Commit();
                }

                foreach (DBSeries series in SeriesSelectDlg.UnCheckedItems)
                {
                    // unignore these series
                    series[DBOnlineSeries.cTraktIgnore] = 0;
                    series.Commit();
                }
            }
        }
Exemple #22
0
        public void UpdateSapstorageSuccess()
        {
            string       sql = "update I_SAPSTORAGE set mesflag='S',pdate=sys_date,ptime=sys_time where mesflag='W'";
            SQLCondition SC  = new SQLCondition(sql);

            this.DataProvider.CustomExecute(SC);
        }
Exemple #23
0
        public void MergeMaterial()
        {
            string       sql = @"MERGE INTO TBLMATERIAL c
                        USING (SELECT MCODE,DQMCODE,MUOM,ROHS,MCHSHORTDESC,MENSHORTDESC,MENLONGDESC,MCHLONGDESC,MODELCODE,MATERIALTYPE,
                        MSTATE1,MSTATE2,MSTATE3,VALIDFROM,EATTRIBUTE8,CDQTY,CDFOR,PURCHASINGGROUP,ABCINDICATOR,MRPTYPE,REORDERPOINT,
                        MRPCONTORLLER,MINIMUMLOTSIZE,ROUNDINGVALUE,SPECIALPROCYREMENT,SAFETYSTOCK,BULKMATERIAL,eattribute1,eattribute2,eattribute3 
                        FROM I_SAPMATERIAL where mesflag='W') ic
                        ON (c.MCODE=ic.MCODE)
                        WHEN MATCHED THEN
                           UPDATE SET c.DQMCODE = ic.DQMCODE,c.MUOM=ic.MUOM,c.ROHS=ic.ROHS,c.MCHSHORTDESC=ic.MCHSHORTDESC,
                           c.MENSHORTDESC=ic.MENSHORTDESC,c.MENLONGDESC=ic.MENLONGDESC,c.MCHLONGDESC=ic.MCHLONGDESC,c.MODELCODE=ic.MODELCODE,
                           c.MATERIALTYPE=ic.MATERIALTYPE,c.MSTATE1=ic.MSTATE1,c.MSTATE2=ic.MSTATE2,c.MSTATE3=ic.MSTATE3,c.VALIDFROM=ic.VALIDFROM,
                           c.EATTRIBUTE8=ic.EATTRIBUTE8,c.CDQTY=ic.CDQTY,c.CDFOR=ic.CDFOR,c.PURCHASINGGROUP=ic.PURCHASINGGROUP,
                           c.ABCINDICATOR=ic.ABCINDICATOR,c.MRPTYPE=ic.MRPTYPE,c.REORDERPOINT=ic.REORDERPOINT,c.MRPCONTORLLER=ic.MRPCONTORLLER,
                           c.MINIMUMLOTSIZE=ic.MINIMUMLOTSIZE,c.ROUNDINGVALUE=ic.ROUNDINGVALUE,c.SPECIALPROCYREMENT=ic.SPECIALPROCYREMENT,
                           c.SAFETYSTOCK=ic.SAFETYSTOCK,c.BULKMATERIAL=ic.BULKMATERIAL,
                           c.eattribute1=ic.eattribute1,c.eattribute2=ic.eattribute2,c.eattribute3=ic.eattribute3,muser='******',mdate=sys_date,mtime=sys_time
                        WHEN NOT MATCHED THEN 
                           INSERT (MCODE,DQMCODE,MUOM,ROHS,MCHSHORTDESC,MENSHORTDESC,MENLONGDESC,MCHLONGDESC,MODELCODE,MATERIALTYPE,
                        MSTATE1,MSTATE2,MSTATE3,VALIDFROM,EATTRIBUTE8,CDQTY,CDFOR,PURCHASINGGROUP,ABCINDICATOR,MRPTYPE,REORDERPOINT,
                        MRPCONTORLLER,MINIMUMLOTSIZE,ROUNDINGVALUE,SPECIALPROCYREMENT,SAFETYSTOCK,BULKMATERIAL,MTYPE,MSTATE,
                        eattribute1,eattribute2,eattribute3,Sourceflag,cuser,cdate,ctime,muser,mdate,mtime) 
                           VALUES(ic.MCODE,ic.DQMCODE,ic.MUOM,ic.ROHS,ic.MCHSHORTDESC,ic.MENSHORTDESC,ic.MENLONGDESC,ic.MCHLONGDESC,
                           ic.MODELCODE,ic.MATERIALTYPE,ic.MSTATE1,ic.MSTATE2,ic.MSTATE3,ic.VALIDFROM,ic.EATTRIBUTE8,ic.CDQTY,ic.CDFOR,
                           ic.PURCHASINGGROUP,ic.ABCINDICATOR,ic.MRPTYPE,ic.REORDERPOINT,ic.MRPCONTORLLER,ic.MINIMUMLOTSIZE,ic.ROUNDINGVALUE,
                           ic.SPECIALPROCYREMENT,ic.SAFETYSTOCK,ic.BULKMATERIAL,'itemtype_finishedproduct',0,
                           ic.eattribute1,ic.eattribute2,ic.eattribute3,'SAP','JOB',sys_date,sys_time,
                           'JOB',sys_date,sys_time)";
            SQLCondition SC  = new SQLCondition(sql);

            this.DataProvider.CustomExecute(SC);
        }
Exemple #24
0
        public IEnumerable <File> GetFileByRole(string roleId)
        {
            var condition = new SQLCondition();

            condition.Expression = "where Role like '%" + roleId + "%'";
            return(_file.Query(condition: condition));
        }
Exemple #25
0
        public void DeleteSapCustomer(int date)
        {
            string       sql = string.Format("Delete I_SAPCUSTOMER  where mesflag='S' and SDATE <{0} ", date);
            SQLCondition SC  = new SQLCondition(sql);

            this.DataProvider.CustomExecute(SC);
        }
Exemple #26
0
        public SQLPage <Role> GetRole(int pageSize, int currentPage, string name)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where name like '%{name}%'";
            return(_role.Query(pageSize, currentPage, condition: condition));
        }
Exemple #27
0
        private void LogData(DataSet ds)
        {
            if (ds != null && ds.Tables[OUTTABLE] != null)
            {
                if (ds.Tables[OUTTABLE].Rows.Count > 0)
                {
                    try
                    {
                        string strInsert;
                        string time = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                        foreach (DataRow row in ds.Tables[OUTTABLE].Rows)
                        {
                            string receiptNO = Convert.ToString(row[OUT_ReceiptNO]);
                            string facLotNo  = Convert.ToString(row[OUT_FacLotNo]);

                            strInsert = @"INSERT INTO  i_tblinvfaclot
                                         (receiptno,faclotno,batchno) VALUES(
                                            '" + receiptNO + "','" + facLotNo + "','" + time + "')";

                            SQLCondition SC = new SQLCondition(strInsert);
                            this.DataProvider.CustomExecute(SC);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
 // -----------------------------------------------------------------------
 //  Build condition set from controls
 // -----------------------------------------------------------------------
 private bool BuildConditionSet(ref SQLCondition cond)
 {
     if ((lbFieldName.SelectedIndex >= 0) && (cbCondition.SelectedIndex >= 0) && (cbValue.Text.Length >= 0))
     {
         cond.fieldtype = _fieldtypes[lbFieldName.SelectedIndex];
         cond.fieldname = lbFieldName.Text;
         cond.condition = cbCondition.Text;
         cond.value     = cbValue.Text;
         if (SQLFilter.ConditionCount == 0)
         {
             cond.logicaloperator = "";
         }
         else
         if (rbAND.Checked)
         {
             cond.logicaloperator = "AND";
         }
         else
         {
             cond.logicaloperator = "OR";
         }
         return(true);
     }
     return(false);
 }
Exemple #29
0
        public AuthenticationSite GetAuthenticationSiteByUuid(string uuid)
        {
            var condition = new SQLCondition();

            condition.Expression = $"where uuid = '{uuid}'";
            return(_authenticationSite.Query(condition).FirstOrDefault());
        }
Exemple #30
0
        QueryBuilder IRepositoryDependent <CuentaMayor> .GetIdsDependentByMasterSelectSQL(int dependentIdCodigo)
        {
            Type         t                         = GetObjModelType();
            Type         apunte                    = typeof(Apunte);
            Type         cuenta                    = typeof(CuentaMayor);
            QueryBuilder qBuilder                  = new QueryBuilder();
            var          ownerConditions           = GetCurrentOwnersCondition(tableAlias: "cuenta");
            var          joinApunteCuentaCondition = new SQLCondition("Id", "cuenta", "IdCuenta", "apu");
            var          joinApunteCondition       = new SQLCondition("Asiento", "apu", "Id", "asi");
            var          owners                    = new string[2] {
                "IdOwnerComunidad", "IdOwnerEjercicio"
            };

            //SELECT asi.Id FROM asiento asi
            //INNER JOIN apunte apu ON apu.Asiento = asi.Id -> joinApuntecondition
            //INNER JOIN cuentamayor cuenta ON cuenta.Id = apu.IdCuenta -> joinApunteCuentacondition
            //WHERE cuenta.IdOwnerComunidad = @idCdad AND cuenta.IdOwnerEjercicio = @idEjer AND apu.IdCuenta = @codCuenta;
            qBuilder
            .Select(new string[] { "Id" }, "asi")
            .From(t, "asi")
            .Join("INNER", apunte, "apu")
            .On(joinApunteCondition)
            .Join("INNER", cuenta, "cuenta")
            .On(joinApunteCuentaCondition)
            .Where(ownerConditions)
            .Condition("AND", new SQLCondition("IdCuenta", "apu", "@codCuenta", ""))
            .SemiColon();
            base.StoreCurrentOwnerConditionsParameters(qBuilder);
            qBuilder.StoreParameter("codCuenta", dependentIdCodigo);

            return(qBuilder);
        }
Exemple #31
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((SQLCondition != null ? SQLCondition.GetHashCode() : 0) * 397) ^
                (Display != null ? Display.GetHashCode() : 0));
     }
 }
Exemple #32
0
    public static string GetLanguageOverride(String sSeriesID)
    {
        string sqlCon = string.Empty;
        SQLCondition cond = new SQLCondition();

        sqlCon = "id = " + sSeriesID;
        cond.AddCustom(sqlCon);

        // Get the language that the user has selected for the serie
        List<DBValue> seriesLanguage = DBOnlineSeries.GetSingleField(DBOnlineSeries.cLanguage, cond, new DBOnlineSeries());

        if ((seriesLanguage.Count > 0) && (seriesLanguage[0] != ""))
        {
            return seriesLanguage[0];
        }
        else
        {
            //If there is no language prefered for the series, the fallback is SelLanguageAsString (en).
            return SelLanguageAsString;
        }
    }
        protected static DBEpisode WaitForSyncedEpisode(DBEpisode episode)
        {
            if (episode == null) return null;
            if (episode[DBOnlineEpisode.cFollwitId] != 0) return episode;

            TimeSpan retryDelay = new TimeSpan(0, 0, 30);
            int limit = 8;
            int epId = episode[DBOnlineEpisode.cID];

            int tries = 0;
            while (tries < limit) {
                // reload the episode from the db to check for changes
                SQLCondition condition = new SQLCondition();
                condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cID, epId, SQLConditionType.Equal);
                condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cFollwitId, 0, SQLConditionType.NotEqual);
                List<DBEpisode> episodes = DBEpisode.Get(condition, false);

                if (episodes.Count > 0) return episodes[0];

                Thread.Sleep(retryDelay);
                tries++;
            }

            return null;
        }
        public static void SyncNewEpisodes(ProgressDialog.ProgressDelegate progress)
        {
            // grab list of all local episodes
            SQLCondition condition = new SQLCondition();
            condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cFollwitId, 0, SQLConditionType.Equal);
            List<DBEpisode> episodes = DBEpisode.Get(condition, false);

            SyncEpisodes(episodes, progress);
        }
        public static void InitUpdateThread()
        {
            if (updateThread != null) {
                updateThread.Abort();
                updateThread = null;
            }

            if (!Enabled) return;

            updateThread = new Thread(new ThreadStart(delegate () {
                while (true) {
                    try {
                        DateTime start = DateTime.Now;
                        MPTVSeriesLog.Write("[follw.it] Beginning update synchronization.", MPTVSeriesLog.LogLevel.Debug);

                        // grab a list of items to update from the server and process them
                        DateTime serverTime;
                        int actionsTaken = 0;
                        List<TaskListItem> tasks = FollwitApi.GetUserTaskList(LastUpdated, out serverTime);
                        foreach (TaskListItem task in tasks) {
                            DBEpisode episode = null;
                            DBSeries series = null;

                            // try to find a cooresponding episode
                            if (task.EpisodeId != 0) {
                                SQLCondition condition = new SQLCondition();
                                condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cFollwitId, task.EpisodeId, SQLConditionType.Equal);
                                List<DBEpisode> episodes = DBEpisode.Get(condition, false);

                                if (episodes.Count > 0) {
                                    episode = episodes[0];
                                    series = DBSeries.Get(episode[DBEpisode.cSeriesID]);
                                }
                            }

                            // try to find a series if we dont have one yet
                            if (task.Task == TaskItemType.NewSeriesRating) {
                                if (task.TvdbSeriesId != 0 && series == null)
                                    series = DBSeries.Get(task.TvdbSeriesId);
                            }

                            // update local data with retrieved info
                            switch (task.Task) {
                                case TaskItemType.NewEpisodeRating:
                                    if (episode == null) continue;

                                    // if we already have a rating and its within one unit of what we are recieving
                                    // ignore it.
                                    if (episode[DBOnlineEpisode.cMyRating] != "" &&
                                        Math.Abs((decimal)(episode[DBOnlineEpisode.cMyRating] - (task.Rating * 2))) <= 1)
                                        continue;

                                    episode[DBOnlineEpisode.cMyRating] = task.Rating * 2;

                                    episode.Commit();
                                    actionsTaken++;
                                    MPTVSeriesLog.Write("[follw.it] Retrieved rating of {3} for '{0} S{1}E{2}'.",
                                        series == null ? "???" : (string) series[DBOnlineSeries.cPrettyName],
                                        episode[DBOnlineEpisode.cCombinedSeason],
                                        episode[DBOnlineEpisode.cEpisodeIndex],
                                        episode[DBOnlineEpisode.cMyRating]);
                                    break;
                                case TaskItemType.NewEpisodeWatchedStatus:
                                    if (episode == null) continue;
                                    episode[DBOnlineEpisode.cWatched] = task.Watched;

                                    episode.Commit();
                                    actionsTaken++;
                                    MPTVSeriesLog.Write("[follw.it] Retrieved watched status of {3} for '{0:00} S{1}E{2}'.",
                                        series == null ? "???" : (string) series[DBOnlineSeries.cPrettyName],
                                        episode[DBOnlineEpisode.cCombinedSeason],
                                        episode[DBOnlineEpisode.cEpisodeIndex],
                                        episode[DBOnlineEpisode.cWatched] == 1 ? "true" : "false");
                                    break;
                                case TaskItemType.NewSeriesRating:
                                    if (series == null) continue;

                                    // if we already have a rating and its within one unit of what we are recieving
                                    // ignore it.
                                    if (series[DBOnlineSeries.cMyRating] != "" &&
                                        Math.Abs((decimal)(series[DBOnlineSeries.cMyRating] - (task.Rating * 2))) <= 1)
                                        continue;

                                    series[DBOnlineSeries.cMyRating] = task.Rating * 2;

                                    series.Commit();
                                    actionsTaken++;
                                    MPTVSeriesLog.Write("[follw.it] Retrieved rating of {1} for '{0}'.",
                                        series[DBOnlineSeries.cPrettyName],
                                        series[DBOnlineSeries.cMyRating]);
                                    break;
                            }
                        }

                        // log final results
                        MPTVSeriesLog.LogLevel logLevel = actionsTaken == 0 ? MPTVSeriesLog.LogLevel.Debug : MPTVSeriesLog.LogLevel.Normal;
                        MPTVSeriesLog.Write(string.Format("[follw.it] Finished update synchronization. Acted on {0}/{1} events. ({2})",
                                            actionsTaken, tasks.Count, DateTime.Now - start), logLevel);

                        LastUpdated = serverTime;

                    }
                    catch (Exception e) {
                        MPTVSeriesLog.Write("[follw.it] Failed update synchronization: {0}", e.StackTrace);
                    }

                    // sleep in 5 second intervals to allow the thread to be aborted as needed.
                    DateTime lastChecked = DateTime.Now;
                    while (DateTime.Now - lastChecked < UpdateFrequency) {
                        Thread.Sleep(5000);
                    }
                }

            }));

            updateThread.IsBackground = true;
            updateThread.Name = "follw.it persistent update thread";
            updateThread.Start();
        }
 public virtual string SerializeCondition(SQLCondition condition)
 {
     return SerializeFieldNameAndTablePrefix(condition.Table, condition.FieldName) + " " + SerializeCondition(condition.Compare, condition.Value);
 }
        public static void SyncAllEpisodes(ProgressDialog.ProgressDelegate progress)
        {
            // grab list of all local episodes
            SQLCondition condition = new SQLCondition();
            condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, 0, SQLConditionType.GreaterThan);
            List<DBEpisode> episodes = DBEpisode.Get(condition, false);

            SyncEpisodes(episodes, progress);
        }
		private void buttonSeriesSelect_Click(object sender, EventArgs e) {												
			SeriesSelect SeriesSelectDlg = new SeriesSelect();
			
            // Set Current View
            string viewTag = "|" + txtViewName.Text + "|"; ;

            // Get list of series in view
            SQLCondition conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, viewTag, SQLConditionType.Like);
            SeriesSelectDlg.CheckedItems = DBSeries.Get(conditions);

            // Get list of series not in view
            conditions = new SQLCondition();
            conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, viewTag, SQLConditionType.NotLike);
            SeriesSelectDlg.UnCheckedItems = DBSeries.Get(conditions);

            // Show series list dialog
			DialogResult result = SeriesSelectDlg.ShowDialog(this);

            if (result == DialogResult.OK) {
                SeriesToAdd = SeriesSelectDlg.CheckedItems;
                SeriesToRemove = SeriesSelectDlg.UnCheckedItems;
            }
		}