Esempio n. 1
0
        private void MoveBestand(EnumerableRowCollection <dtsAlles.AfleveringsRow> afleveringen, FileInfo bestand, Match match)
        {
            int seizoen = int.Parse(match.Groups[1].Value);
            int afl     = int.Parse(match.Groups[2].Value);

            var aflevering = afleveringen.FirstOrDefault(a => a.Seizoen == seizoen && a.Nummer == afl);

            if (aflevering != null)
            {
                string newName = "Afl. " + aflevering.Nummer + " - " + aflevering.Naam
                                 .Replace("\\", ", ")
                                 .Replace("/", ", ")
                                 .Replace(":", " -")
                                 .Replace("*", "^")
                                 .Replace("?", "")
                                 .Replace("\"", "'")
                                 .Replace("<", " ")
                                 .Replace(">", " ")
                                 .Replace("|", ", ");

                if (bestand.Extension.ToLower().Equals(".srt"))
                {
                    newName += ".dut";
                }

                string fullName = bestand.FullName.Replace(bestand.Name, newName + bestand.Extension);

                if (File.Exists(fullName) == false)
                {
                    bestand.MoveTo(fullName);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 ///     hàm thực hiện việc hủy xác nhận thông tin
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdHuyXacNhan_Click(object sender, EventArgs e)
 {
     if (grdDonThuoc.GetCheckedRows().Length <= 0)
     {
         Utility.ShowMsg("Bạn chọn bản ghi cần chuyển sang", "Thông báo", MessageBoxIcon.Error);
         return;
     }
     foreach (GridEXRow gridExRow in grdDonThuoc.GetCheckedRows())
     {
         EnumerableRowCollection <DataRow> query = from thuoc in m_dtDonThuoc.AsEnumerable()
                                                   where
                                                   Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.PresId]) ==
                                                   Utility.Int32Dbnull(gridExRow.Cells[KcbDonthuoc.Columns.PresId].Value)
                                                   select thuoc;
         if (query.Any())
         {
             DataRow firstrow = query.FirstOrDefault();
             if (firstrow != null)
             {
                 firstrow["IsChon"] = 0;
             }
             firstrow.AcceptChanges();
         }
         query = from thuoc in m_dtPhieuLinh.AsEnumerable()
                 where
                 Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.]) ==
Esempio n. 3
0
        protected IEnumerable <Column> GetColumnDetails(bool getIndexDetails)
        {
            EnumerableRowCollection <DataRow> indexColumns = null;

            if (getIndexDetails)
            {
                indexColumns = _connection.GetSchema("IndexColumns").AsEnumerable()
                               .OrderBy(row => row.Field <string>(4)) //Schema
                               .ThenBy(row => row.Field <string>(5))  //Table
                               .ThenBy(row => row.Field <int>(7));    //Ordinal
            }

            return(_connection.GetSchema("Columns").AsEnumerable()
                   .Select(row => {
                Column column = null;

                var schema = row.Field <string>(1);
                var table = row.Field <string>(2);
                var name = row.Field <string>(3);

                if (getIndexDetails && indexColumns != null)
                {
                    DataRow indexRow = indexColumns.FirstOrDefault(r =>
                                                                   schema.Equals(r.Field <string>(4)) &&
                                                                   table.Equals(r.Field <string>(5)) &&
                                                                   name.Equals(r.Field <string>(6)));
                    if (indexRow != null)
                    {
                        column = new IndexedColumn {
                            IndexKind = indexRow.Field <byte>(8) == 36 ? IndexKind.PrimaryKey : IndexKind.Unique
                        };
                    }
                }

                if (column == null)
                {
                    column = new Column();
                }

                column.Schema = schema;
                column.Table = table;
                column.Name = name;
                column.Ordinal = row.Field <int>(4);
                column.IsNullable = row.Field <string>(6).Equals("YES", StringComparison.OrdinalIgnoreCase);
                column.Type = GetDataColumnType(row.Field <string>(7));
                column.DbType = row.Field <string>(7);

                return column;
            })
                   .OrderBy(c => c.Schema).ThenBy(c => c.Table).ThenBy(c => c.Ordinal));
        }
Esempio n. 4
0
        public void Execute(SqlTransaction transaction)
        {
            foreach (DataRow row in _tablePersonFirm.Rows)
            {
                object idOsobaFirma      = row["IdOsobaFirma"];
                object idNazivOsobaFirma = row["IdNazivOsobaFirma"];
                object adresa            = row["Adresa"];
                object idSjediste        = row["IdSjediste"];
                object jmbgJib           = row["JMBR/JIB"];
                object idTipOsobe        = row["IdTipOsobe"];
                object datumUnosa        = row["DatumUnosa"];

                string tempAdresa = string.Format("{0},{1}", adresa, sjediste);

                EnumerableRowCollection <DataRow> results = from myRow in _tableNamePersonFirm.AsEnumerable()
                                                            where myRow.Field <int>("IdNazivOsobaFirma") == (int)idNazivOsobaFirma
                                                            select myRow;

                DataRow relatedRow = results.FirstOrDefault();

                object nazivOsobaFirma   = relatedRow["NazivOsobaFirma"];
                object datumUnosaRelated = relatedRow["DatumUnosa"];

                SqlCommand cmd = new SqlCommand("TaxPayer.Save", SQLSingleton.Instance.SqlConnection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure,
                    Transaction = transaction
                };

                cmd.Parameters.AddWithValue("@Name", nazivOsobaFirma);
                cmd.Parameters.AddWithValue("@Description", null);
                cmd.Parameters.AddWithValue("@CreatedBy", datumUnosa);
                cmd.Parameters.AddWithValue("@TaxNumber", null);
                cmd.Parameters.AddWithValue("@Address", tempAdresa);
                cmd.Parameters.AddWithValue("@CantonID", null);
                cmd.Parameters.AddWithValue("@MunicipalityID", null);
                cmd.Parameters.AddWithValue("@JMBG_JIB", jmbgJib);
                cmd.Parameters.AddWithValue("@CountryID", null);
                cmd.Parameters.AddWithValue("@Phone", null);
                cmd.Parameters.AddWithValue("@Fax", null);
                cmd.Parameters.AddWithValue("@Email", null);
                cmd.Parameters.AddWithValue("@TaxPayerTypeID", 2);

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 5
0
        public void Execute(SqlTransaction transaction)
        {
            foreach (DataRow row in _tableApplicant.Rows)
            {
                object idPodnosilacZahtjeva      = row["IdPodnosilacZahtjeva"];
                object idNazivPodnosilacZahtjeva = row["IdNazivPodnosilacZahtjeva"];
                object idSjediste = row["IdSjediste"];
                object datumUnosa = row["DatumUnosa"];

                EnumerableRowCollection <DataRow> results = from myRow in _tableNameOfApplicant.AsEnumerable()
                                                            where myRow.Field <int>("IdNazivPodnosilacZahtjeva") == (int)idNazivPodnosilacZahtjeva
                                                            select myRow;

                DataRow relatedRow = results.FirstOrDefault();

                object relatedNazivPodnosilacZahtjeva = relatedRow["NazivPodnosilacZahtjeva"];
                object relatedDatumUnosa = relatedRow["DatumUnosa"];

                SqlCommand cmd = new SqlCommand("TaxPayer.Save", SQLSingleton.Instance.SqlConnection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure,
                    Transaction = transaction
                };

                cmd.Parameters.AddWithValue("@Name", relatedNazivPodnosilacZahtjeva);
                cmd.Parameters.AddWithValue("@Description", null);
                cmd.Parameters.AddWithValue("@CreatedBy", 9);
                cmd.Parameters.AddWithValue("@TaxNumber", null);
                cmd.Parameters.AddWithValue("@Address", );
                cmd.Parameters.AddWithValue("@CantonID", null);
                cmd.Parameters.AddWithValue("@MunicipalityID", null);
                cmd.Parameters.AddWithValue("@JMBG_JIB", null);
                cmd.Parameters.AddWithValue("@CountryID", null);
                cmd.Parameters.AddWithValue("@Phone", null);
                cmd.Parameters.AddWithValue("@Fax", null);
                cmd.Parameters.AddWithValue("@Email", null);
                cmd.Parameters.AddWithValue("@TaxPayerTypeID", null);

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 6
0
        private void ToolStripMenuItemCopyCongViec_Click(object sender, EventArgs e)
        {
            if (congviec.Count() > 0 && _IdCongViecTienCong != 0)
            {
                //Copy công việc (chia tiền công cho các thợ làm cùng công việc)
                decimal tiencong = congviec.Sum(m => m.Field <decimal>("TienCong"));

                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = @"UPDATE ThoDichVu_TienCongThoTam
                                    SET TienCong = @TienCong WHERE IdTienCong = @IdTienCong AND IdBaoDuong = @IdBaoDuong";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@TienCong", tiencong / (congviec.Count() + 1));
                cmd.Parameters.AddWithValue("@IdTienCong", congviec.FirstOrDefault().Field <int>("IdTienCong"));
                cmd.Parameters.AddWithValue("@IdBaoDuong", txtID3.Text);

                Class.datatabase.ExcuteNonQuery(cmd);

                cmd.CommandText = @"INSERT INTO ThoDichVu_TienCongThoTam
                                            (IdTienCong, NgaySuaChua, IdCongTy, IdBaoDuong, NoiDungBD, TienCong, TienKhachTra)
                                            VALUES (@IdTienCong,@NgaySuaChua,@IdCongTy,@IdBaoDuong,@NoiDungBD,@TienCong,@TienKhachTra)";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@IdTienCong", congviec.FirstOrDefault().Field <int>("IdTienCong"));
                cmd.Parameters.AddWithValue("@NgaySuaChua", congviec.FirstOrDefault().Field <DateTime>("NgaySuaChua"));
                cmd.Parameters.AddWithValue("@IdCongTy", congviec.FirstOrDefault().Field <int>("IdCongTy"));
                cmd.Parameters.AddWithValue("@IdBaoDuong", congviec.FirstOrDefault().Field <int>("IdBaoDuong"));
                cmd.Parameters.AddWithValue("@NoiDungBD", congviec.FirstOrDefault().Field <string>("NoiDungBD"));
                cmd.Parameters.AddWithValue("@TienCong", tiencong / (congviec.Count() + 1));
                cmd.Parameters.AddWithValue("@TienKhachTra", 0);

                Class.datatabase.ExcuteNonQuery(cmd);

                cmd.CommandText = "select * from ThoDichVu_TienCongThoTam where IdCongTy=@IdCongTy and IdBaoDuong=@IdBaoDuong";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@IdCongTy", Class.CompanyInfo.idcongty);
                cmd.Parameters.AddWithValue("@IdBaoDuong", txtID3.Text);

                DtgBaoDuongTheoTien.DataSource = Class.datatabase.getData(cmd);
            }
        }
Esempio n. 7
0
 public static List <string> Columns(this EnumerableRowCollection <DataRow> dataRows)
 {
     return(dataRows?.FirstOrDefault().Columns());
 }
Esempio n. 8
0
        public void Execute(SqlTransaction transaction)
        {
            foreach (DataRow row in _tableCH.Rows)
            {
                //row from odluke_CH table
                object id                    = row["ID"];
                object idAPCH                = row["IdAPCH_odluke"];
                object prezime               = row["Prezime"];
                object ime                   = row["Ime"];
                object osnovOdluke           = row["Osnov_odluke"];
                object datumOdluke           = row["DatumOdluke"];
                object nasBroj               = row["Nas_br"];
                object datumProtokola        = row["DatumProtokola"];
                object iznosGlavni           = row["Iznos"];
                object troskovi              = row["Troskovi"];
                object kamata                = row["Kamata"];
                object ukupno                = row["Ukupno"];
                object datumObrazacBudzet    = row["Datum obrac - budzet"];
                object datumPlacanja         = row["DatumPlacanja"];
                object idStatusPlacanja      = row["IdStatusPlacanja"];
                object idBudzetskaGodina     = row["IdBudzetskaGodina"];
                object datumPrijema          = row["Datum prijema"];
                object brojResenjaOIzvrsenju = row["Broj rješenja o izvršenju"];
                object datumResenjaIzvrsenja = row["DatumRjesenjaIzvrsenja"];
                object idVrstaObaveze        = row["IdVrstaObaveze"];
                object vrsatObaveze          = row["VrstaObaveze"];
                object napomena              = row["Napomena"];
                object iznosValuta           = row["IznosValuta"];
                object idVrstaValute         = row["IdVrstaValute"];
                object brojDokumentaVeze     = row["BrojDokumentaVeze"];
                object datumDokumentaVeze    = row["DatumDokumentaVeze"];
                object isplataNaIme          = row["IsplataNaIme"];

                EnumerableRowCollection <DataRow> results = from myRow in _tableAPCH.AsEnumerable()
                                                            where myRow.Field <int>("IdAPCH_odluke") == (int)idAPCH
                                                            select myRow;

                DataRow relatedRow = results.FirstOrDefault();

                object apchPrezime               = relatedRow["Prezime"];
                object apchIme                   = relatedRow["Ime"];
                object apchBrojOdluke            = relatedRow["BrojAPCH_odluke"];
                object apchDatumOdluke           = relatedRow["DatumAPCH_odluke"];
                object apchBrojProtokola         = relatedRow["BrojProtokola"];
                object apchDatumDokumenta        = relatedRow["DatumDokumenta"];
                object apchDatumPrijema          = relatedRow["DatumPrijema"];
                object apchBrojResenjaIzvrsenja  = relatedRow["BrojRjesenjaIzvrsenja"];
                object apchDatumResenjaIzvrsenja = relatedRow["DatumRjesenjaIzvrsenja"];
                object apchNapomena              = relatedRow["Napomena"];
                object apchDatumUnosa            = relatedRow["DatumUnosa"];

                int taxPayerID = Utility.GetTaxPayerID(ime.ToString(), prezime.ToString());

                SqlCommand cmd = new SqlCommand("DecisionInsert", SQLSingleton.Instance.SqlConnection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure,
                    Transaction = transaction
                };

                cmd.Parameters.AddWithValue("@DecisionNumber", apchBrojOdluke);
                cmd.Parameters.AddWithValue("@ProtocolNumber", apchBrojProtokola);
                cmd.Parameters.AddWithValue("@TaxPayerID", taxPayerID);
                cmd.Parameters.AddWithValue("@BudgetInstitutionID", 87);
                cmd.Parameters.AddWithValue("@PaymentMethodID", 19);
                cmd.Parameters.AddWithValue("@NumberOfInstallment", 1);
                cmd.Parameters.AddWithValue("@LoanPrincipal", iznosGlavni);
                cmd.Parameters.AddWithValue("@Interest", kamata);
                cmd.Parameters.AddWithValue("@CourtCost", troskovi);
                cmd.Parameters.AddWithValue("@Total", ukupno);
                cmd.Parameters.AddWithValue("@DecisionDate", datumOdluke);
                cmd.Parameters.AddWithValue("@ProtocolDate", datumProtokola);
                cmd.Parameters.AddWithValue("@InNameOfTaxPayerID", 0);        //iz Tax Payer
                cmd.Parameters.AddWithValue("@SubjectTypeID", "Nepoznato");
                cmd.Parameters.AddWithValue("@SubjectStatusID", "Nepoznato"); //?
                cmd.Parameters.AddWithValue("@ObligationTypeID", idVrstaObaveze);
                cmd.Parameters.AddWithValue("@Doknjizavanje", false);
                cmd.Parameters.AddWithValue("@DatumDoknjizavanja", null);
                cmd.Parameters.AddWithValue("@IznosDoknjizavanjaSudTros", null);
                cmd.Parameters.AddWithValue("@IznosDoknjizavanjaGlavnice", null);
                cmd.Parameters.AddWithValue("@IznosDoknjizavanjaKamate", null);
                cmd.Parameters.AddWithValue("@Note", apchNapomena);
                cmd.Parameters.AddWithValue("@CreatedBy", 9);

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 9
0
        internal Result PopulateElementData(UIApplication uiApp, ref string msg, DataTable dataTable)
        {
            List <string> ParameterNames = (from dc in dataTable.Columns.Cast <DataColumn>() select dc.ColumnName).ToList();

            ParameterNames.RemoveAt(0);
            //Test to see if the list of parameter names is defined at all, if not -- break.
            if (ParameterNames.IsNullOrEmpty())
            {
                BuildingCoderUtilities.ErrorMsg("Parameter names are incorrectly defined. Please reselect the EXCEL workbook.");
                return(Result.Failed);
            }
            ;
            Document doc = uiApp.ActiveUIDocument.Document;
            //string filename = path;
            StringBuilder sbFeedback = new StringBuilder();

            //Failure feedback
            Element elementRefForFeedback = null;

            FilteredElementCollector collector = Shared.Filter.GetElementsWithConnectors(doc);

            //prepare input variables which are initialized when looping the elements
            string eFamilyType = null; string columnName = null;

            //query is using the variables in the loop to query the dataset
            EnumerableRowCollection <string> query = from value in dataTable.AsEnumerable()
                                                     where value.Field <string>(0) == eFamilyType
                                                     select value.Field <string>(columnName);

            var pQuery = from p in new plst().LPAll
                         where p.Domain == "ELEM"
                         select p;

            //Debugging
            //StringBuilder sbParameters = new StringBuilder();

            using (Transaction trans = new Transaction(doc, "Initialize PCF parameters"))
            {
                trans.Start();

                //Loop all elements pipes and fittings and accessories, setting parameters as defined in the dataset
                try
                {
                    //Reporting the number of different elements initialized
                    int pNumber = 0, fNumber = 0, aNumber = 0;
                    foreach (Element element in collector)
                    {
                        //Feedback
                        elementRefForFeedback = element;

                        //Filter out elements in ARGD (Rigids) system type
                        Cons cons = new Cons(element);
                        if (cons.Primary.MEPSystemAbbreviation(doc) == "ARGD")
                        {
                            continue;
                        }

                        //reporting
                        if (string.Equals(element.Category.Name.ToString(), "Pipes"))
                        {
                            pNumber++;
                        }
                        else if (string.Equals(element.Category.Name.ToString(), "Pipe Fittings"))
                        {
                            fNumber++;
                        }
                        else if (string.Equals(element.Category.Name.ToString(), "Pipe Accessories"))
                        {
                            aNumber++;
                        }

                        eFamilyType = element.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString();
                        foreach (string parameterName in ParameterNames) // <-- ParameterNames must be correctly initialized!!!
                        {
                            columnName = parameterName;                  //This is needed to execute query correctly by deferred execution
                            string parameterValue = query.FirstOrDefault();
                            if (string.IsNullOrEmpty(parameterValue))
                            {
                                continue;
                            }
                            Guid parGuid = (from d in pQuery where d.Name == parameterName select d.Guid).First();
                            //Check if parGuid returns a match
                            if (parGuid == null)
                            {
                                BuildingCoderUtilities.ErrorMsg("Wrong parameter set. Select ELEMENT parameters.");
                                return(Result.Failed);
                            }

                            //Writing the parameter data
                            //Implementing Overwrite or Append here
                            if (iv.Overwrite)
                            {
                                element.get_Parameter(parGuid).Set(parameterValue);
                            }
                            else
                            {
                                Parameter par = element.get_Parameter(parGuid);
                                if (string.IsNullOrEmpty(par.ToValueString()))
                                {
                                    par.Set(parameterValue);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }

                        //sbParameters.Append(eFamilyType);
                        //sbParameters.AppendLine();
                    }

                    //sbParameters.Append(eFamilyType);
                    //sbParameters.AppendLine();


                    sbFeedback.Append(pNumber + " Pipes initialized.\n" + fNumber + " Pipe fittings initialized.\n" + aNumber + " Pipe accessories initialized.");
                    BuildingCoderUtilities.InfoMsg(sbFeedback.ToString());
                    //excelReader.Close();

                    //// Debugging
                    //// Clear the output file
                    //File.WriteAllBytes(InputVars.OutputDirectoryFilePath + "Parameters.pcf", new byte[0]);

                    //// Write to output file
                    //using (StreamWriter w = File.AppendText(InputVars.OutputDirectoryFilePath + "Parameters.pcf"))
                    //{
                    //    w.Write(sbParameters);
                    //    w.Close();
                    //}
                }
                catch (Autodesk.Revit.Exceptions.OperationCanceledException)
                {
                    return(Result.Cancelled);
                }

                catch (Exception ex)
                {
                    msg = ex.Message;
                    BuildingCoderUtilities.ErrorMsg($"Population of parameters failed with the following exception: \n" + msg +
                                                    $"\n For element {elementRefForFeedback.Id.IntegerValue}.");
                    trans.RollBack();
                    return(Result.Failed);
                }

                trans.Commit();
            }

            return(Result.Succeeded);
        }
Esempio n. 10
0
        internal Result PopulatePipelineData(UIApplication uiApp, ref string msg, DataTable dataTable)
        {
            List <string> ParameterNames = (from dc in dataTable.Columns.Cast <DataColumn>() select dc.ColumnName).ToList();

            //ParameterNames.RemoveAt(0);
            //ParameterNames.RemoveAt(0);
            //Test to see if the list of parameter names is defined at all, if not -- break.
            if (ParameterNames.IsNullOrEmpty())
            {
                BuildingCoderUtilities.ErrorMsg("Parameter names are incorrectly defined. Please reselect the EXCEL workbook.");
                return(Result.Failed);
            }
            ;
            Document      doc        = uiApp.ActiveUIDocument.Document;
            StringBuilder sbFeedback = new StringBuilder();

            //Get the systems of things and get the SystemTypes
            //Collector for PipingSystems
            FilteredElementCollector collector   = new FilteredElementCollector(doc);
            IList <Element>          elementList = collector.OfClass(typeof(PipingSystem)).ToElements();
            //Collector returns Element, cast to PipingSystem
            IList <PipingSystem> systemList = elementList.Cast <PipingSystem>().ToList();
            //Get the PipingSystemType Id from the PipingSystem elements
            IList <ElementId> systemTypeIdList = systemList.Select(sys => sys.GetTypeId()).ToList();
            //Retrieve PipingSystemType from doc
            IEnumerable <Element> systemTypeList = from id in systemTypeIdList select doc.GetElement(id);

            //Group PipingSystemType by Name and retrieve first element of group -> equals to filtering a list to contain only unique elements
            List <Element> sQuery = (from st in systemTypeList
                                     group st by new { st.Name } //http://stackoverflow.com/a/9589705/6073998 {st.Name, st.Attribute1, st.Attribute2}
                                     into stGroup
                                     select stGroup.First()).ToList();

            //prepare input variables which are initialized when looping the elements
            string sysAbbr = null; string columnName = null;

            //query is using the variables in the loop to query the dataset
            EnumerableRowCollection <string> query = from value in dataTable.AsEnumerable()
                                                     where value.Field <string>(0) == iv.PCF_PROJECT_IDENTIFIER &&
                                                     value.Field <string>(1) == sysAbbr
                                                     select value.Field <string>(columnName);

            //Get a query for pipeline parameters
            var pQuery = from p in new plst().LPAll
                         where p.Domain == "PIPL" &&
                         p.ExportingTo != "LDT"       //<- LDT parameters are read directly from EXCEL to PCF file.
                         select p;

            //Debugging
            //StringBuilder sbParameters = new StringBuilder();

            using (Transaction trans = new Transaction(doc, "Initialize Pipeline PCF parameters"))
            {
                trans.Start();

                //Loop all elements pipes and fittings and accessories, setting parameters as defined in the dataset
                try
                {
                    //Reporting the number of different elements initialized
                    int sNumber = 0;
                    foreach (Element pipeSystemType in sQuery)
                    {
                        //reporting
                        sNumber++;

                        sysAbbr = pipeSystemType.get_Parameter(BuiltInParameter.RBS_SYSTEM_ABBREVIATION_PARAM).AsString();
                        foreach (string parameterName in ParameterNames) // <-- ParameterNames must be correctly initialized!!!
                        {
                            columnName = parameterName;                  //This is needed to execute query correctly by deferred execution
                            string parameterValue = query.FirstOrDefault();
                            if (string.IsNullOrEmpty(parameterValue))
                            {
                                continue;
                            }
                            Guid parGuid = (from d in pQuery.ToList() where d.Name == parameterName select d.Guid).FirstOrDefault();
                            //Check if parGuid returns a match
                            if (parGuid == null)
                            {
                                continue;
                            }
                            Parameter par = pipeSystemType.get_Parameter(parGuid);
                            if (par == null)
                            {
                                continue;
                            }
                            par.Set(parameterValue);
                        }

                        //sbParameters.Append(eFamilyType);
                        //sbParameters.AppendLine();
                    }

                    //sbParameters.Append(eFamilyType);
                    //sbParameters.AppendLine();
                    //}

                    sbFeedback.Append(sNumber + " Pipe Systems (Pipelines) initialized.\n");
                    BuildingCoderUtilities.InfoMsg(sbFeedback.ToString());
                    //excelReader.Close();

                    //// Debugging
                    //// Clear the output file
                    //File.WriteAllBytes(InputVars.OutputDirectoryFilePath + "Parameters.pcf", new byte[0]);

                    //// Write to output file
                    //using (StreamWriter w = File.AppendText(InputVars.OutputDirectoryFilePath + "Parameters.pcf"))
                    //{
                    //    w.Write(sbParameters);
                    //    w.Close();
                    //}
                }
                catch (Autodesk.Revit.Exceptions.OperationCanceledException)
                {
                    return(Result.Cancelled);
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    BuildingCoderUtilities.ErrorMsg("Population of parameters failed with the following exception: \n" + msg);
                    trans.RollBack();
                    return(Result.Failed);
                }
                trans.Commit();
            }
            return(Result.Succeeded);
        }
Esempio n. 11
0
        public static DataTable Aggregate(EnumerableRowCollection <DataRow> resu, Criteria currentCriteria)
        {
            IEnumerable <string> columnsToGroupBy = currentCriteria.agKey.Split(',');
            IEnumerable <string> sumsToSelect     = currentCriteria.agSum.Split(',');

            var keys = currentCriteria.agKey.Split(',');

            var groupList = resu.GroupBy(x => new NTuple <object>(from column in columnsToGroupBy select x[column])); //.Select(val => new { nK=val.FirstOrDefault().Field<string>(keys[0])+"~"+ val.FirstOrDefault().Field<string>(keys[1]), total=val.Sum(c=>Convert.ToDecimal(c.Field<string>(sumsToSelect.FirstOrDefault()))).ToString()});//new NTuple<object>(from sum in sumsToSelect select val[sum])

            if (resu.Count() == 0)
            {
                return(new DataTable());
            }

            DataTable aggregatedTable = resu.FirstOrDefault().Table.Clone();

            aggregatedTable.Columns.Add("AggregatedKey", typeof(string));

            /*foreach (DataColumn col in resu.ElementAtOrDefault(0).Table.Columns)
             * {
             *  table.Columns.Add(col.ColumnName, col.DataType);
             * }*/

            //DataRow toAdd = aggregatedTable.NewRow();
            //toAdd.Table.Columns.Add("AggregatedKey", typeof(string));
            //toAdd["AggregatedKey"] = aggregatedKey;



            foreach (var group in groupList)
            {
                string  aggregatedKey = "";
                DataRow toAdd         = group.FirstOrDefault();
                if (!(toAdd.Table.Columns.Contains("AggregatedKey")))
                {
                    toAdd.Table.Columns.Add("AggregatedKey", typeof(string));
                }
                for (int i = 1; i < group.Count(); i++)
                {                                                                    //each row in the group (except first)
                    for (int j = 0; j < group.ElementAt(i).Table.Columns.Count; j++) //each column in row
                    {
                        var colName = group.ElementAt(i).Table.Columns[j].ColumnName;
                        if (sumsToSelect.Contains(colName))
                        {
                            toAdd[colName] = Convert.ToDouble(toAdd[colName].ToString()) + Convert.ToDouble(group.ElementAt(i)[colName].ToString());
                        }
                        else if (toAdd[colName].ToString() != group.ElementAt(i)[colName].ToString())
                        {
                            toAdd[colName] = null;//group.ElementAt(i)[colName].ToString();
                        }
                    }
                }
                for (int i = 0; i < columnsToGroupBy.Count(); i++)
                {
                    if (i == 0)
                    {
                        aggregatedKey = toAdd[columnsToGroupBy.ElementAt(i)].ToString();
                    }
                    else
                    {
                        aggregatedKey += "~" + toAdd[columnsToGroupBy.ElementAt(i)].ToString();
                    }
                }
                toAdd["AggregatedKey"] = aggregatedKey;
                aggregatedTable.Rows.Add(toAdd.ItemArray);
            }

            return(aggregatedTable);
        }
        public void Execute(SqlTransaction transaction)
        {
            foreach (DataRow row in _tableJudgmentIR.Rows)
            {
                object idPresudeIR            = row["IdPresudeIR"];
                object brojPresudeIR          = row["BrojPresudeIR"];
                object datumPresudeIR         = row["DatumPresudeIR"];
                object brojProtokola          = row["BrojProtokola"];
                object datumProtokola         = row["DatumProtokola"];
                object datumPrijemaURad       = row["DatumPrijemaURad"];
                object idStatusPredmeta       = row["IdStatusPredmeta"];
                object idVrstaPredmeta        = row["IdVrstaPredmeta"];
                object nazivPredmeta          = row["NazivPredmeta"];
                object idDostavljenoOd        = row["IdDostavljenoOd"];
                object brojDostavljenoOd      = row["BrojDostavljenoOd"];
                object datumDostavljenoOd     = row["DatumDostavljenoOd"];
                object brojPresudeOdIR        = row["BrojPresudeOdIR"];
                object datumPresudeOdIR       = row["DatumPresudeOdIR"];
                object idBanka                = row["IdBanka"];
                object brojDokFMFPravob       = row["BrojDokFMFPravob"];
                object datumFMFPravobran      = row["DatumFMFPravobran"];
                object brojPravobran          = row["BrojPravobran"];
                object datumPravobran         = row["DatumPravobran"];
                object idTipRjesenjaPravobran = row["IdTipRjesenjaPravobran"];
                object rješenjePravobran      = row["RješenjePravobran"];
                object idPresigniranoKome     = row["IdPresigniranoKome"];
                object presigniranoKada       = row["PresigniranoKada"];
                object presigniranoRazlog     = row["PresigniranoRazlog"];
                object idRazlogPresigniranja  = row["IdRazlogPresigniranja"];
                object kontrola1              = row["Kontrola1"];
                object napomena               = row["Napomena"];
                object datumUnosa             = row["DatumUnosa"];

                EnumerableRowCollection <DataRow> results = from myRow in _tableJudgmentPayment.AsEnumerable()
                                                            where myRow.Field <int>("IdPresudeIR") == (int)idPresudeIR
                                                            select myRow;

                DataRow relatedRow = results.FirstOrDefault();

                object idPresudeIsplata       = relatedRow["IdPresudeIsplata"];
                object idOsobaFirma           = relatedRow["IdOsobaFirma"];
                object brojRjesenjaIsplate    = relatedRow["BrojRjesenjaIsplate"];
                object datumRjesenjaIsplate   = relatedRow["DatumRjesenjaIsplate"];
                object idStatusOsobaFirma     = relatedRow["IdStatusOsobaFirma"];
                object datumSpremnostiIsplate = relatedRow["DatumSpremnostiIsplate"];
                object idVrstaObaveze         = relatedRow["IdVrstaObaveze"];
                object idOsnovZaPlacanje      = relatedRow["IdOsnovZaPlacanje"];
                object idNacinPlacanja        = relatedRow["IdNacinPlacanja"];
                object brojRata             = relatedRow["BrojRata"];
                object zaIsplatu            = relatedRow["ZaIsplatu"];
                object glavnicaRataP        = relatedRow["GlavnicaRataP"];
                object kamataP              = relatedRow["KamataP"];
                object kamataGlavP          = relatedRow["KamataGlavP"];
                object kamataTP             = relatedRow["KamataTP"];
                object troskoviIzvrsenja    = relatedRow["TroskoviIzvrsenja"];
                object troskoviParnPostupka = relatedRow["TroskoviParnPostupka"];
                object datumPlacanja        = relatedRow["DatumPlacanja"];
                object brojIzvoda           = relatedRow["BrojIzvoda"];
                object idGodinaBudzeta      = relatedRow["IdGodinaBudzeta"];
                object idBudzetskiKorisnik  = relatedRow["IdBudzetskiKorisnik"];
                object idBankaRelated       = relatedRow["IdBanka"];
                object brojDokZaprimanja    = relatedRow["BrojDokZaprimanja"];
                object datumZaprimanja      = relatedRow["DatumZaprimanja"];
                object datumBankaZaprimanja = relatedRow["DatumBankaZaprimanja"];
                object idSjediste           = relatedRow["IdSjediste"];
                object brojRacuna           = relatedRow["BrojRacuna"];
                object brojPartije          = relatedRow["BrojPartije"];
                object glavnicaISP          = relatedRow["GlavnicaISP"];
                object kamataISP            = relatedRow["KamataISP"];
                object kamataGlavISP        = relatedRow["KamataGlavISP"];
                object kamataTPSP           = relatedRow["KamataTPSP"];
                object sudTroskoviSP        = relatedRow["SudTroskoviSP"];
                object kontrola2            = relatedRow["Kontrola2"];
                object napomenaRelated      = relatedRow["Napomena"];
                object datumUnosaRelated    = relatedRow["DatumUnosa"];

                string statusPlacanja           = (datumPlacanja == null) ? "Neplaćeno" : "Plaćeno";
                double tempTroskoviIzvrsenja    = (troskoviIzvrsenja == null) ? 0 : Convert.ToDouble(troskoviIzvrsenja);
                double tempTroskoviParnPostupka = (troskoviParnPostupka == null) ? 0 : Convert.ToDouble(troskoviParnPostupka);
                double totalSudTroskovi         = tempTroskoviIzvrsenja + tempTroskoviParnPostupka;

                double tempKamataISP     = (kamataISP == null) ? 0 : Convert.ToDouble(kamataISP);
                double tempKamataGlavISP = (kamataGlavISP == null) ? 0 : Convert.ToDouble(kamataGlavISP);
                double tempKamataTPSP    = (kamataTPSP == null) ? 0 : Convert.ToDouble(kamataTPSP);
                double tempTotal         = tempKamataISP + tempKamataGlavISP + tempKamataTPSP;


                SqlCommand cmd = new SqlCommand("JudgmentAndExecutiveResult.Save", SQLSingleton.Instance.SqlConnection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure,
                    Transaction = transaction
                };

                cmd.Parameters.AddWithValue("@JudgmentAndExecutiveResultNumber", brojPresudeIR);
                cmd.Parameters.AddWithValue("@ProtocolNumber", brojProtokola);
                cmd.Parameters.AddWithValue("@TaxPayerID", );
                cmd.Parameters.AddWithValue("@BudgetInstitutionID", idBudzetskiKorisnik);
                cmd.Parameters.AddWithValue("@PaymentMethodID", idNacinPlacanja);
                cmd.Parameters.AddWithValue("@NumberOfInstallment", 1);
                cmd.Parameters.AddWithValue("@LoanPrincipalOrInstallment", glavnicaRataP);
                cmd.Parameters.AddWithValue("@LoanPrincipalTotal", glavnicaRataP);
                cmd.Parameters.AddWithValue("@CourtCostsIzvr", tempTroskoviIzvrsenja);
                cmd.Parameters.AddWithValue("@CourtCostsPar", tempTroskoviParnPostupka);
                cmd.Parameters.AddWithValue("@CourtCostTotal", totalSudTroskovi);
                cmd.Parameters.AddWithValue("@JudgmentAndExecutiveResultDate", datumPresudeIR);
                cmd.Parameters.AddWithValue("@ProtocolDate", datumProtokola);
                cmd.Parameters.AddWithValue("@SubjectTypeID", idVrstaPredmeta);
                cmd.Parameters.AddWithValue("@SubjectStatusID", idStatusPredmeta);
                cmd.Parameters.AddWithValue("@ObligationTypeID", "Nepoznato");
                cmd.Parameters.AddWithValue("@Interest", tempKamataISP);
                cmd.Parameters.AddWithValue("@InterestGlav", tempKamataGlavISP);
                cmd.Parameters.AddWithValue("@InterestTp", tempKamataTPSP);
                cmd.Parameters.AddWithValue("@InterestTotal", tempTotal);
                cmd.Parameters.AddWithValue("@AdditionalAccounting", null);
                cmd.Parameters.AddWithValue("@AdditionalAccountingDate", null);
                cmd.Parameters.AddWithValue("@AdditionalAccountingLegalCosts", null);
                cmd.Parameters.AddWithValue("@AdditionalAccountingPrincipal", null);
                cmd.Parameters.AddWithValue("@AdditionalAccountingInterestRate", null);
                cmd.Parameters.AddWithValue("@Note", napomena);
                cmd.Parameters.AddWithValue("@CreatedBy", 9);
                cmd.Parameters.AddWithValue("@BankID", idBanka);
                cmd.Parameters.AddWithValue("@ExecutiveResultDate", datumPresudeOdIR);
                cmd.Parameters.AddWithValue("@ExecutiveResultNumber", brojPresudeOdIR);
                cmd.Parameters.AddWithValue("@ActDate", null);
                cmd.Parameters.AddWithValue("@ActNumber", null);
                cmd.Parameters.AddWithValue("@JudgementDeliveryID", idDostavljenoOd);

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 13
0
        /// <summary>
        ///     hàm thực hiện việc chuyên thông tin sang bên phải
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdChuyenSang_Click(object sender, EventArgs e)
        {
            if (grdPres.GetCheckedRows().Length <= 0)
            {
                Utility.ShowMsg("Bạn chọn bản ghi cần chuyển sang", "Thông báo", MessageBoxIcon.Error);
                return;
            }
            foreach (GridEXRow gridExRow in grdPres.GetCheckedRows())
            {
                int pres_id = Utility.Int32Dbnull(gridExRow.Cells["Pres_ID"].Value, -1);
                EnumerableRowCollection <DataRow> query = from thuoc in m_dtDonThuoc.AsEnumerable()
                                                          where
                                                          Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.PresId]) == pres_id
                                                          select thuoc;
                if (query.Any())
                {
                    DataRow firstrow = query.FirstOrDefault();
                    if (firstrow != null)
                    {
                        firstrow["IsChon"] = 1;
                    }
                    firstrow.AcceptChanges();
                }

                EnumerableRowCollection <DataRow> query1 = from thuoc in m_dtPhieuLinh.AsEnumerable()
                                                           where Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.PresId]) == pres_id
                                                           select thuoc;
                if (!query1.Any())
                {
                    DataRow firstrow1 = query.FirstOrDefault();
                    if (firstrow1 != null)
                    {
                        DataRow dr = m_dtPhieuLinh.NewRow();
                        dr["IsChon"]  = 1;
                        dr["Pres_ID"] = Utility.Int32Dbnull(firstrow1["Pres_ID"]);
                        if (m_dtPhieuLinh.Columns.Contains("ID_DTRI"))
                        {
                            dr["ID_DTRI"] = Utility.Int32Dbnull(firstrow1["Treat_ID"]);
                        }
                        if (m_dtPhieuLinh.Columns.Contains("Treat_ID"))
                        {
                            dr["Treat_ID"] = Utility.Int32Dbnull(firstrow1["Treat_ID"]);
                        }
                        dr["Patient_Name"]  = Utility.sDbnull(firstrow1["Patient_Name"]);
                        dr["Year_Of_Birth"] = Utility.Int32Dbnull(firstrow1["Year_Of_Birth"]);
                        dr["Patient_Code"]  = Utility.sDbnull(firstrow1["Patient_Code"]);
                        dr["Patient_Addr"]  = Utility.sDbnull(firstrow1["Patient_Addr"]);
                        dr["Patient_ID"]    = Utility.Int32Dbnull(firstrow1["Patient_ID"]);
                        if (m_dtPhieuLinh.Columns.Contains("Pres_Date"))
                        {
                            dr["Pres_Date"] = Convert.ToDateTime(firstrow1["Pres_Date"]);
                        }
                        if (m_dtPhieuLinh.Columns.Contains("Pres_Name"))
                        {
                            dr["Pres_Name"] = Utility.sDbnull(firstrow1["Pres_Name"]);
                        }
                        m_dtPhieuLinh.Rows.Add(dr);
                    }
                }
                else
                {
                    DataRow firstrow = query1.FirstOrDefault();
                    if (firstrow != null)
                    {
                        firstrow["IsChon"] = 1;
                    }
                    firstrow.AcceptChanges();
                }
            }

            Modifycommand();
        }
Esempio n. 14
0
        private void AdTPhieuCapphatNoitru()
        {
            try
            {
                if (p_phieuCapPhatThuoc != null)
                {
                    EnumerableRowCollection <DataRow> query = from phieu in p_phieuCapPhatThuoc.AsEnumerable()
                                                              where
                                                              Utility.Int32Dbnull(phieu[TPhieuCapphatNoitru.Columns.IdCapphat]) ==
                                                              Utility.Int32Dbnull(txtID_CAPPHAT.Text)
                                                              select phieu;
                    if (!query.Any())
                    {
                        DataRow             drv             = p_phieuCapPhatThuoc.NewRow();
                        TPhieuCapphatNoitru objPhieuCapphat = TPhieuCapphatNoitru.FetchByID(Utility.Int32Dbnull(txtID_CAPPHAT.Text));
                        Utility.FromObjectToDatarow(objPhieuCapphat, ref drv);
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_KHOA_LINH"))
                        {
                            drv["ten_KHOA_LINH"] = Utility.sDbnull(txtTen_KHOA_LINH.Text);
                        }
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_kho_xuat"))
                        {
                            drv["ten_kho_xuat"] = Utility.sDbnull(txtTenKho.Text);
                        }
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_nvien"))
                        {
                            drv["ten_nvien"] = Utility.sDbnull(globalVariables.gv_sStaffName);
                        }
                        p_phieuCapPhatThuoc.Rows.Add(drv);
                    }
                    else
                    {
                        DataRow drv = query.FirstOrDefault();
                        if (drv != null)
                        {
                            drv["ID_CAPPHAT"] = Utility.Int32Dbnull(txtID_CAPPHAT.Text);

                            drv["ID_KHO_XUAT"] = Utility.Int32Dbnull(txtId_KhoXuat.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_kho_xuat"))
                            {
                                drv["ten_kho_xuat"] = Utility.sDbnull(txtTenKho.Text);
                            }
                            drv["ID_KHOA_LINH"] = Utility.Int32Dbnull(txtID_KHOA_LINH.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_KHOA_LINH"))
                            {
                                drv["ten_KHOA_LINH"] = Utility.sDbnull(txtTen_KHOA_LINH.Text);
                            }
                            drv["ID_NVIEN"] = Utility.Int32Dbnull(txtID_NVIEN.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_nvien"))
                            {
                                drv["ten_nvien"] = Utility.sDbnull(txtTen_NVIEN.Text);
                            }
                            drv["NGAY_NHAP"]  = dtNgayCapPhat.Text;
                            drv["MOTA_THEM"]  = Utility.sDbnull(txtMOTA_THEM.Text);
                            drv["Loai_Phieu"] = radThuoc.Checked ? "THUOC" : "VT";
                            drv["Da_CapPhat"] = chkDa_CapPhat.Checked;
                        }
                        drv.AcceptChanges();
                        p_phieuCapPhatThuoc.AcceptChanges();
                    }
                }
            }
            catch (Exception exception)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(exception.ToString());
                }
            }
        }
Esempio n. 15
0
        private string KiemtraCamchidinhchungphieu(int id_thuoc, string ten_chitiet)
        {
            string _reval = "";
            string _tempt = "";
            var    lstKey = new List <string>();
            string _key   = "";

            //Kiểm tra dịch vụ đang thêm có phải là dạng Single-Service hay không?
            DataRow[] _arrSingle =
                m_dtDanhmucthuoc.Select(DmucThuoc.Columns.SingleService + "=1 AND " + DmucThuoc.Columns.IdThuoc + "=" +
                                        id_thuoc);
            if (_arrSingle.Length > 0 &&
                m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "<>" + id_thuoc).Length > 0)
            {
                return(string.Format("Single-Service: {0}", ten_chitiet));
            }
            //Kiểm tra các dịch vụ đã thêm có cái nào là Single-Service hay không?
            List <int> lstID =
                m_dtDonthuocChitiet.AsEnumerable()
                .Select(c => Utility.Int32Dbnull(c[KcbDonthuocChitiet.Columns.IdThuoc], 0))
                .Distinct()
                .ToList();
            EnumerableRowCollection <DataRow> q = from p in m_dtDanhmucthuoc.AsEnumerable()
                                                  where Utility.ByteDbnull(p[DmucThuoc.Columns.SingleService], 0) == 1 &&
                                                  lstID.Contains(Utility.Int32Dbnull(p[DmucThuoc.Columns.IdThuoc], 0))
                                                  select p;

            if (q.Any())
            {
                return(string.Format("Single-Service: {0}",
                                     Utility.sDbnull(q.FirstOrDefault()[DmucThuoc.Columns.TenThuoc], "")));
            }
            //Lấy các cặp cấm chỉ định chung cùng nhau
            DataRow[] arrDr =
                m_dtqheCamchidinhChungphieu.Select(QheCamchidinhChungphieu.Columns.IdDichvu + "=" + id_thuoc);
            DataRow[] arrDr1 =
                m_dtqheCamchidinhChungphieu.Select(QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung + "=" +
                                                   id_thuoc);
            foreach (DataRow dr in arrDr)
            {
                DataRow[] arrtemp =
                    m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "=" +
                                               Utility.sDbnull(
                                                   dr[QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung]));
                if (arrtemp.Length > 0)
                {
                    foreach (DataRow dr1 in arrtemp)
                    {
                        _tempt = string.Empty;
                        _key   = id_thuoc + "-" + Utility.sDbnull(dr1[KcbDonthuocChitiet.Columns.IdThuoc], "");
                        if (!lstKey.Contains(_key))
                        {
                            lstKey.Add(_key);
                            _tempt = string.Format("{0} - {1}", ten_chitiet,
                                                   Utility.sDbnull(dr1[DmucThuoc.Columns.IdThuoc], ""));
                        }
                        if (_tempt != string.Empty)
                        {
                            _reval += _tempt + "\n";
                        }
                    }
                }
            }
            foreach (DataRow dr in arrDr1)
            {
                DataRow[] arrtemp =
                    m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "=" +
                                               Utility.sDbnull(dr[QheCamchidinhChungphieu.Columns.IdDichvu]));
                if (arrtemp.Length > 0)
                {
                    foreach (DataRow dr1 in arrtemp)
                    {
                        _tempt = string.Empty;
                        _key   = id_thuoc + "-" + Utility.sDbnull(dr1[KcbDonthuocChitiet.Columns.IdThuoc], "");
                        if (!lstKey.Contains(_key))
                        {
                            lstKey.Add(_key);
                            _tempt = string.Format("{0} - {1}", ten_chitiet,
                                                   Utility.sDbnull(dr1[DmucThuoc.Columns.TenThuoc], ""));
                        }
                        if (_tempt != string.Empty)
                        {
                            _reval += _tempt + "\n";
                        }
                    }
                }
            }
            return(_reval);
        }
Esempio n. 16
0
        private void MoveBestandForHome(EnumerableRowCollection <dtsAlles.AfleveringsRow> afleveringen, FileInfo bestand, Match match)
        {
            string name = match.Groups[2].Value.Replace(".dut", "");

            var aflevering = afleveringen.FirstOrDefault(a => a.Naam.Equals(name));

            if (aflevering != null)
            {
                var serie = DAC.SeriesTA.GetData().FirstOrDefault(s => s.ID == aflevering.SerieID);
                //string newName = "Afl. " + aflevering.Nummer + " - " + aflevering.Naam
                //    .Replace("\\", ", ")
                //    .Replace("/", ", ")
                //    .Replace(":", " -")
                //    .Replace("*", "^")
                //    .Replace("?", "")
                //    .Replace("\"", "'")
                //    .Replace("<", " ")
                //    .Replace(">", " ")
                //    .Replace("|", ", ");
                string newName = serie.Naam.Replace(": ", " ") + " - s" + aflevering.Seizoen.ToString("D2") + "e" + aflevering.Nummer.ToString("D2");

                if (bestand.Extension.ToLower().Equals(".srt"))
                {
                    newName += ".dut";
                }

                string fullName = bestand.FullName.Replace(bestand.Name, newName + bestand.Extension);

                if (File.Exists(fullName) == false)
                {
                    bestand.MoveTo(fullName);
                }
            }
            else
            {
                var aflv  = afleveringen.Where(a => a.Nummer == int.Parse(match.Groups[1].Value));
                var serie = DAC.SeriesTA.GetData().FirstOrDefault(s => s.ID == aflv.First().SerieID);

                foreach (var afl in aflv)
                {
                    string naam = afl.Naam
                                  .Replace("\\", ", ")
                                  .Replace("/", ", ")
                                  .Replace(":", " -")
                                  .Replace("*", "^")
                                  .Replace("?", "")
                                  .Replace("\"", "'")
                                  .Replace("<", " ")
                                  .Replace(">", " ")
                                  .Replace("|", ", ");

                    if (naam.Equals(name))
                    {
                        string newName = serie.Naam.Replace(": ", " ") + " - s" + afl.Seizoen.ToString("D2") + "e" + afl.Nummer.ToString("D2");

                        string fullName = bestand.FullName.Replace(bestand.Name, newName + bestand.Extension);

                        if (File.Exists(fullName) == false)
                        {
                            bestand.MoveTo(fullName);
                        }

                        break;
                    }
                }
            }
        }
Esempio n. 17
0
        public static void ExtractElementConfiguration(DataSet dataSet, ElementSymbol es)
        {
            try
            {
                DataTableCollection dataTables = dataSet.Tables;
                DataTable           dataTable;

                //Handle all pipelines or separate configuration setting
                if (iv.ConfigureAll)
                {
                    dataTable = (from DataTable dt in dataTables
                                 where string.Equals(dt.TableName, "All pipelines")
                                 select dt).FirstOrDefault();
                }
                else
                {
                    dataTable = (from DataTable dt in dataTables
                                 where string.Equals(dt.TableName, es.PipelineReference)
                                 select dt).FirstOrDefault();
                }

                //query the element family and type is using the variables in the loop to query the dataset
                EnumerableRowCollection <string> query = from value in dataTable.AsEnumerable()
                                                         where value.Field <string>(0) == es.PipelineReference
                                                         select value.Field <string>(es.ElementType);

                string familyAndType = query.FirstOrDefault().ToString();
                FilteredElementCollector collector   = new FilteredElementCollector(PCF_Importer_form._doc);
                ElementParameterFilter   filter      = Filter.ParameterValueFilter(familyAndType, BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM);
                LogicalOrFilter          classFilter = Filter.FamSymbolsAndPipeTypes();
                Element familySymbol = collector.WherePasses(classFilter).WherePasses(filter).FirstOrDefault();

                if (es.ElementType == "PIPE")
                {
                    es.PipeType = (PipeType)familySymbol;
                }
                else
                {
                    es.FamilySymbol = (FamilySymbol)familySymbol;
                }

                //query the corresponding pipe family and type to add to the element symbol
                //This is because pipe type is needed to create certain fittings
                if (es.ElementType != "PIPE" || es.ElementType != "OLET") //Exclude olets -- they are handled next
                {
                    EnumerableRowCollection <string> queryPipeType = from value in dataTable.AsEnumerable()
                                                                     where value.Field <string>(0) == es.PipelineReference
                                                                     select value.Field <string>("PIPE");

                    string pipeTypeName = queryPipeType.FirstOrDefault();
                    FilteredElementCollector collectorPipeType  = new FilteredElementCollector(PCF_Importer_form._doc);
                    ElementParameterFilter   filterPipeTypeName = Filter.ParameterValueFilter(pipeTypeName, BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM);
                    Element pipeType = collectorPipeType.OfClass(typeof(PipeType)).WherePasses(filterPipeTypeName).FirstOrDefault();
                    es.PipeType = (PipeType)pipeType;
                }
                if (es.ElementType == "OLET") //Get the TAP pipetype for olets
                {
                    EnumerableRowCollection <string> queryPipeType = from value in dataTable.AsEnumerable()
                                                                     where value.Field <string>(0) == "Olet"
                                                                     select value.Field <string>("PIPE");

                    string pipeTypeName = queryPipeType.FirstOrDefault();
                    FilteredElementCollector collectorPipeType  = new FilteredElementCollector(PCF_Importer_form._doc);
                    ElementParameterFilter   filterPipeTypeName = Filter.ParameterValueFilter(pipeTypeName, BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM);
                    Element pipeType = collectorPipeType.OfClass(typeof(PipeType)).WherePasses(filterPipeTypeName).FirstOrDefault();
                    es.PipeType = (PipeType)pipeType;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }