- 1
_workflowQueue = new Queue<IWorkflowInfo>(_workflowQueue.Where(w => !(w == workflow || w.WorkflowGuid == workflow.WorkflowGuid)));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
_workflowQueue = new Queue<IWorkflowInfo>(_workflowQueue.Where(w => !(w == workflow || w.WorkflowGuid == workflow.WorkflowGuid)));
Вот как надо делать, если из очереди нужно удалить произвольный элемент.
Использовать List?! Это для слабаков!
+1
$product = ORM::factory('product');
// $product-> ... = ...;
$price = ORM::factory('price');
$price->save();
$product->price = $price->id;
$product->save();
$price->product = $product->id;
// $price-> ... = ...;
$price->save();
Для гарантии
+1
<?php
echo '<script type="text/javascript">';
echo 'var categories = new Array();';
if (count($categData)) {
foreach ($categData as $id => $name) {
echo ' categories[' . $id . '] = "' . $name . '";';
}
}
echo ' </script>';
?>
+1
select value, value_type from b_iblock_element_property WHERE id = **;
b_iblock_element_property.value: a:2:{s:4:"TYPE";s:4:"text";s:4:"TEXT";s:17:"Хорошее состояние";}
b_iblock_element_property.value_type: text
bitrix <3
+1
static int Cols (double[,] Arr, out int rows)
{
int n = Arr.GetLength(0);
int m = Arr.GetLength(1);
rows=0;
int i=0;
int j=0;
for (; j < m;j++)
{
i = 0;
while (i < n-1 & Arr[i, j] < (Arr[i+1 , j]))
{
i++;
}
if (i == n-1)
rows++;
}
int k = 0;
i = 0;
for (; i < n; i++)
{
j = 0;
while (j < m-1 & Arr[i, j] < (Arr[i, j+1 ]))
{
j++;
}
if (j == m - 1)
k++;
}
return k;
}
+1
void CDiagram::readDomElement( const QDomElement & de )
{
// ...
QString sstratum = de.attribute( "stratum", "1" );
bool ok = false;
int istratum = sstratum.toInt( &ok );
setStratum( ok ? istratum : CTSWConfig::m_SyncStratum );
// ...
}
Парсинг xml конфигов, код не мой, но надо переделывать.
+1
public static CategoryAttribute Build(string category_name, string attribute_type, string attribute_name, object attribute_value)
{
try
{
CategoryAttribute document_attribute;
switch(attribute_type)
{
case "string":
case "double_as_string":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.String);
break;
case "string_as_date":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.DateTime);
break;
case "int":
case "double_as_int":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Integer);
break;
case "double":
document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Double);
break;
default:
throw new ApplicationException("Не верно настроен тип данных атрибута '" + attribute_name + "' категории '" + category_name + "'.");
}
if (attribute_value == null)
return document_attribute;// атрибут остался неопределенным
switch (document_attribute.Type)
{
case TypeEnum.String:
{
switch (attribute_type)
{
case "string":
{
if (!(attribute_value is string))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.sValue = attribute_value as string;
} break;
case "double_as_string":
{
if (!(attribute_value is double))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.sValue = ((double)attribute_value).ToString();
} break;
}
}
break;
case TypeEnum.Integer:
{
switch (attribute_type)
{
case "int":
{
if (!(attribute_value is int))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.iValue = (int)attribute_value;
} break;
case "double_as_int":
{
if (!(attribute_value is double))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
attribute_type + "'.");
document_attribute.iValue = (int)(double)attribute_value;
} break;
}
}
break;
case TypeEnum.Double:
{
if (!(attribute_value is float || attribute_value is double || attribute_value is int || attribute_value is long))
throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
+ "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" + attribute_type + "'.");
document_attribute.dValue = (double)attribute_value;
}
break;
}
return document_attribute;
catch (Exception e)
{
//...
}
}
Создание объекта типа CategoryAttribute.
+1
var cloths = {
<?php foreach ($clothList as $cloth): ?>
"<?=$cloth->id()?>": {
"id": <?=$cloth->id()?>,
"name": "<?=$cloth->name()?>",
"public_name": "<?=str_replace('"', '\"', $cloth->public_name())?>"
},
<?php endforeach; ?>
"dummy": {}
};
+1
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
txtLog.Clear();
string customXMLFileName = dlgOpen.FileName;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(customXMLFileName);
foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
{
if (node.Name == "Surfaces")
{
foreach (XmlNode childNode in node.ChildNodes)
{
txtLog.AppendText(childNode.Name.ToString() + Environment.NewLine);
foreach (XmlNode _childNode in childNode.ChildNodes)
{
if (_childNode.Name == "SourceData")
{
foreach (XmlNode __childNode in _childNode.ChildNodes)
{
txtLog.AppendText(__childNode.Name.ToString() + Environment.NewLine);
if (__childNode.Name == "Breaklines")
{
foreach (XmlNode ___childNode in __childNode.ChildNodes)
{
txtLog.AppendText(___childNode.Name.ToString() + Environment.NewLine);
XmlNode dataNode = ___childNode.LastChild;
string txtData = dataNode.InnerText;
txtLog.AppendText(txtData + Environment.NewLine);
}
}
}
}
}
}
}
}
Невнимательное чтение MSDN привело к такому плачевному результату. А всего лишь хотелось прочитать значение дочерних нод Breaklines....
GetElementsByTagName в помощь....
+1
<script>
var link=window.location.href;
var arr = link.split("#");
document.write("<script> function fuk_flash(){");
if (arr[1] != "d4"){
document.write("appD4.setAttribute(\"style\", \"display:none\");");
}
if (arr[1] != "d5"){
document.write("appD5.setAttribute(\"style\", \"display:none\");");
}
if (arr[1] != "f"){
document.write("appF.setAttribute(\"style\", \"display:none\");");
}
document.write("}<\/script>");
</script>
<script>
window.onload=fuk_flash;
</script>
Когда на странице 3 флэшки, необходимо показывать только одну, исходя из атрибутов ссылки, и когда ни одна из них не показывает полосу загрузки (при своем немалом весе) после обращения к себе, и когда все более-менее адекватные решения провалились.
(Но проблема оказалась в том, что флэш находил в адресе страницы # и переставал грузиться)